my.bumble.android: better handling for missing conversation id in database

This commit is contained in:
Dima Gerasimov 2023-03-16 20:27:46 +00:00 committed by karlicoss
parent 9db5f318fb
commit 457797bdfb

View file

@ -114,6 +114,9 @@ def _key(r: EntitiesRes):
return r return r
_UNKNOWN_PERSON = "UNKNOWN_PERSON"
def messages() -> Iterator[Res[Message]]: def messages() -> Iterator[Res[Message]]:
id2person: Dict[str, Person] = {} id2person: Dict[str, Person] = {}
id2msg: Dict[str, Message] = {} id2msg: Dict[str, Message] = {}
@ -126,8 +129,12 @@ def messages() -> Iterator[Res[Message]]:
continue continue
if isinstance(x, _Message): if isinstance(x, _Message):
reply_to_id = x.reply_to_id 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: try:
person = id2person[x.conversation_id]
reply_to = None if reply_to_id is None else id2msg[reply_to_id] reply_to = None if reply_to_id is None else id2msg[reply_to_id]
except Exception as e: except Exception as e:
yield e yield e