diff --git a/CHANGELOG.md b/CHANGELOG.md index 178ebf08..249e4796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,20 @@ # Changelog -## [1.8.1a1](https://github.com/NeonGeckoCom/neon-utils/tree/1.8.1a1) (2023-12-15) +## [1.8.2a2](https://github.com/NeonGeckoCom/neon-utils/tree/1.8.2a2) (2023-12-27) -[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.8.0...1.8.1a1) +[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.8.2a1...1.8.2a2) **Merged pull requests:** -- Update `add_event` patching to work around FakeBus compat. [\#490](https://github.com/NeonGeckoCom/neon-utils/pull/490) ([NeonDaniel](https://github.com/NeonDaniel)) +- Use OpenStreetMap geocoder to work around maps.co API changes [\#493](https://github.com/NeonGeckoCom/neon-utils/pull/493) ([NeonDaniel](https://github.com/NeonDaniel)) + +## [1.8.2a1](https://github.com/NeonGeckoCom/neon-utils/tree/1.8.2a1) (2023-12-20) + +[Full Changelog](https://github.com/NeonGeckoCom/neon-utils/compare/1.8.1...1.8.2a1) + +**Merged pull requests:** + +- Better default profile handling [\#492](https://github.com/NeonGeckoCom/neon-utils/pull/492) ([NeonDaniel](https://github.com/NeonDaniel)) diff --git a/neon_utils/location_utils.py b/neon_utils/location_utils.py index 6cbb721a..0234030f 100644 --- a/neon_utils/location_utils.py +++ b/neon_utils/location_utils.py @@ -39,7 +39,7 @@ # geocode.maps.co nominatim.openstreetmap.org -_NOMINATIM_DOMAIN = "geocode.maps.co" +_NOMINATIM_DOMAIN = "nominatim.openstreetmap.org" def set_nominatim_domain(domain: str): diff --git a/neon_utils/user_utils.py b/neon_utils/user_utils.py index ee4d4bb1..769d696e 100644 --- a/neon_utils/user_utils.py +++ b/neon_utils/user_utils.py @@ -102,9 +102,13 @@ def get_user_prefs(message: Message = None) -> dict: return default_user_config for profile in message.context.get(profile_key): - if profile["user"]["username"] == username: - return dict(dict_update_keys(profile, default_user_config)) + try: + if profile["user"]["username"] == username: + return dict(dict_update_keys(profile, default_user_config)) + except KeyError: + LOG.error(f"Malformed profile in message context: {profile}") LOG.warning(f"No preferences found for {username} in {message.context}") + default_user_config['user']['username'] = username return default_user_config diff --git a/tests/user_util_tests.py b/tests/user_util_tests.py index 63103fc1..b9c52a3c 100644 --- a/tests/user_util_tests.py +++ b/tests/user_util_tests.py @@ -66,6 +66,15 @@ def test_get_user_prefs(self): self.assertIn("address", user_2["user"]) self.assertEqual(test_message_2.context['user_profiles'][1], user_2) + missing_profile = get_user_prefs(Message("", {}, + {"username": "test", + "user_profiles": [{}]})) + self.assertEqual(missing_profile["user"]["username"], "test") + missing_profile_2 = get_user_prefs(Message("", {}, + {"username": "test2", + "user_profiles": [{}]})) + self.assertEqual(missing_profile_2["user"]["username"], "test2") + def wrapper(message, valid_dict): self.assertEqual(get_user_prefs(), valid_dict) diff --git a/version.py b/version.py index 7b0c30fe..c6ad4662 100644 --- a/version.py +++ b/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "1.8.1" +__version__ = "1.8.2"