fbmessenger.android: expose contacts

This commit is contained in:
Dima Gerasimov 2023-12-28 18:07:57 +00:00 committed by karlicoss
parent a0ce666024
commit 3ec362fce9

View file

@ -111,12 +111,18 @@ def _process_db_msys(db: sqlite3.Connection) -> Iterator[Res[Entity]]:
senders: Dict[str, Sender] = {}
for r in db.execute('SELECT CAST(id AS TEXT) AS id, name FROM contacts'):
s = Sender(
id=r['id'],
id=r['id'], # looks like it's server id? same used on facebook site
name=r['name'],
)
# NOTE https://www.messenger.com/t/{contant_id} for permalink
senders[s.id] = s
yield s
# TODO what is fb transport??
# TODO what are client_contacts?? has pk or something
# TODO client_threads/client_messages -- possibly for end to end encryption or something?
# TODO can we get it from db? could infer as the most common id perhaps?
self_id = config.facebook_id
thread_users: Dict[str, List[Sender]] = {}
@ -237,6 +243,15 @@ def _process_db_threads_db2(db: sqlite3.Connection) -> Iterator[Res[Entity]]:
)
def contacts() -> Iterator[Res[Sender]]:
for x in unique_everseen(_entities):
if isinstance(x, Exception):
yield x
continue
if isinstance(x, Sender):
yield x
def messages() -> Iterator[Res[Message]]:
senders: Dict[str, Sender] = {}
msgs: Dict[str, Message] = {}