From 3ec362fce90ae9f8d5b6a9b248c07168ba194089 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Thu, 28 Dec 2023 18:07:57 +0000 Subject: [PATCH] fbmessenger.android: expose contacts --- my/fbmessenger/android.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/my/fbmessenger/android.py b/my/fbmessenger/android.py index fa313ea..ecf0eb0 100644 --- a/my/fbmessenger/android.py +++ b/my/fbmessenger/android.py @@ -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] = {}