Skip to content

messagix: Receive Instagram typing indicators#156

Merged
radon-at-beeper merged 29 commits intomainfrom
rr-instagram-typing-recv
Sep 10, 2025
Merged

messagix: Receive Instagram typing indicators#156
radon-at-beeper merged 29 commits intomainfrom
rr-instagram-typing-recv

Conversation

@radon-at-beeper
Copy link
Collaborator

@radon-at-beeper radon-at-beeper commented Aug 29, 2025

Receive typing indicators from Instagram. This required reverse-engineering a totally novel websocket API that it seems nobody else on the Internet (that I was able to find) had published details of. Note that, surprisingly, typing indicators are sent via the same API on both Facebook and Instagram; however, they are only received using that same API on Facebook, instead being received via the other API on Instagram.

In messagix/dgw I have provided a reusable client for interacting with this API, which is able to encode and decode a subset of the available message frame types, enough to subscribe to typing indicators and parse those received. Received DGW messages are sent back to the bridge connector and handled in handleMetaEvent similarly to Lightspeed messages.

There are special ID schemas for Instagram, one used for user IDs and one used for thread IDs. Therefore, to interpret received typing indicators, the bridge must look up the corresponding FBIDs for these legacy IDs. The thread ID information was already being received as an additional message (LSDeleteThenInsertIgThreadInfo) that the bridge was not previously aware of, but the user ID information is only sometimes sent (in LSDeleteThenInsertIGContactInfo), and therefore I needed to update the bridge to react to LSVerifyContactRowExists by queuing a GetContactsFullTask for any contacts still missing information; this gives parity with the behavior of the web client. Instagram user and thread IDs are stored persistently in the attached database, since they are not expected to change over time. There are wrapper methods for handling both the in-memory and database caches of these ID types.

I wanted to separate out the DGW socket code into a separate module, but this required moving around a few other symbols that the Lightspeed socket code was accessing as private members. Most egregiously I am passing in a MessagixClient interface to the DGW module, since otherwise there would be an import cycle. Let me know if you can think of a way to improve the modularity.

The DGW socket code was originally based upon the Lightspeed socket code, but was rewritten to be more clearly correct to me from a concurrency perspective.

This has been tested to work with receiving Instagram typing notifications from another person who is typing in the Instagram web client, when I am using Beeper desktop with the self-hosted Instagram bridge running locally.

@radon-at-beeper radon-at-beeper marked this pull request as ready for review September 8, 2025 19:38
@radon-at-beeper radon-at-beeper changed the title Receive Instagram typing indicators messagix: Receive Instagram typing indicators Sep 8, 2025
Copy link
Member

@tulir tulir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good except slightly too much of the code moved inside if platform == instagram

@radon-at-beeper radon-at-beeper merged commit 0ceb36f into main Sep 10, 2025
11 checks passed
@radon-at-beeper radon-at-beeper deleted the rr-instagram-typing-recv branch September 10, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants