From 457797bdfb838a59cfa5ad7b79375a9fa62aedbc Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Thu, 16 Mar 2023 20:27:46 +0000 Subject: [PATCH] my.bumble.android: better handling for missing conversation id in database --- my/bumble/android.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/my/bumble/android.py b/my/bumble/android.py index 2fa6bd8..6bc27dc 100644 --- a/my/bumble/android.py +++ b/my/bumble/android.py @@ -114,6 +114,9 @@ def _key(r: EntitiesRes): return r +_UNKNOWN_PERSON = "UNKNOWN_PERSON" + + def messages() -> Iterator[Res[Message]]: id2person: Dict[str, Person] = {} id2msg: Dict[str, Message] = {} @@ -126,8 +129,12 @@ def messages() -> Iterator[Res[Message]]: continue if isinstance(x, _Message): reply_to_id = x.reply_to_id + # hmm seems that sometimes there are messages with no corresponding conversation_info? + # possibly if user never clicked on conversation before.. + person = id2person.get(x.conversation_id) + if person is None: + person = Person(user_id=x.conversation_id, user_name=_UNKNOWN_PERSON) try: - person = id2person[x.conversation_id] reply_to = None if reply_to_id is None else id2msg[reply_to_id] except Exception as e: yield e