instagram.android: fix missing id

This commit is contained in:
Dima Gerasimov 2022-12-23 02:27:11 +00:00 committed by karlicoss
parent 11b6e51c90
commit 9c432027b5

View file

@ -119,15 +119,17 @@ def _entities() -> Iterator[Res[Union[User, _Message]]]:
# todo use TypedDict? # todo use TypedDict?
for f in inputs(): for f in inputs():
with sqlite_connect_immutable(f) as db: with sqlite_connect_immutable(f) as db:
for (self_uid, thread_json) in select(('user_id', 'thread_info'), 'FROM threads', db=db): for (self_uid, thread_json) in select(('user_id', 'thread_info'), 'FROM threads', db=db):
j = json.loads(thread_json) j = json.loads(thread_json)
# todo in principle should leave the thread attached to the message? # todo in principle should leave the thread attached to the message?
# since thread is a group of users? # since thread is a group of users?
# inviter usually contains our own user # inviter usually contains our own user
for r in [j['inviter'], *j['recipients']]: for r in [j['inviter'], *j['recipients']]:
# id disappeared and seems that pk_id is in use now (around december 2022)
uid = r.get('id') or r.get('pk_id')
assert uid is not None
yield User( yield User(
id=str(r['id']), # for some reason it's int in the db id=str(uid), # for some reason it's int in the db
full_name=r['full_name'], full_name=r['full_name'],
username=r['username'], username=r['username'],
) )