Nerixyz / instagram_mqtt

Realtime and Push Notification (FBNS) support for the instagram-private-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not getting message reply data

andresespinosapc opened this issue · comments

I'm not receiving text replies when new direct messages arrive through realtime. I have already upgraded the APP_VERSION in the instagram-private-api package and I receive these messages when requesting them from there.

Here's my code:

const ig = withRealtime(new IgApiClient());
ig.realtime.on('message', data => console.log(data));
await ig.realtime.connect({ irisData: await ig.feed.directInbox().request() });
commented

Currently, there's a property missing in the iris data with the app version.

Do you know how to fix it? I can do it

The problem is not solved, the message still comes without the repliedMessage attribute.

commented

But which text replies? Replies to a story? Never the less, please provide logs or similar.

I'm referring to direct message's replies, those that look like this:
Screenshot_20210112_163529

When getting a thread from the HTTP API the items come with a repliedToMessage attribute with the item which was replied. I'm using appVersion 169.1.0.29.135. When using an older version such as 130 this attribute does not come with the items.
Screenshot_20210112_163650

I looked at the messages received on Instagram web (that are a reply to another message) and here is an example:

3��/ig_message_sync�
[{
  "event":"patch",
  "data": 
[{
"op":"add",
"path":"/direct_v2/threads/340282366841710300949128150183054920436/items/29708450331468083091593423560376320",
"value":"{
  \"item_id\": \"29708450331468083091593423560376320\",
  \"user_id\": 34668226400,
  \"timestamp\": 1610498319527770,
  \"item_type\": \"text\",
  \"text\": \"Bla\",
  \"client_context\": \"6754919542955933588\",
  \"replied_to_message\": {\"item_id\": \"29708449394376085138062594514354176\", \"user_id\": 34668226400, \"timestamp\": 1610498268727911, \"item_type\": \"text\", \"text\": \"Fldkccdc\", \"client_context\": \"6754919329962863312\", \"show_forward_attribution\": false, \"is_shh_mode\": false},
  \"show_forward_attribution\": false,
  \"is_shh_mode\": false}"}],
"message_type":1,"seq_id":30800,"mutation_token":"6754919542955933588","realtime":true}]

As you can see, it includes a replied_to_message attribute.

I tried replacing irisData in realtime.client.ts with the following without luck:

data: {
  seq_id,
  snapshot_at_ms,
  snapshot_app_version: 'web',
  subscription_type: 'message'
},

That's the irisData that is sent through the web app.

So maybe the problem is not the app version, or the app version is sent in another request that we haven't figured out yet.

I noticed that the request url on Instagram web is edge-chat.instagram.com/chat, while on this library it seems like it's edge-mqtt.facebook.com. Maybe the endpoint changed in newer versions of Instagram, but I don't know how to check it on the mobile app.

commented

Great research, but you have to keep in mind that Instagram Web isn't like the app. The mqtts client is similar but the connection process isn't. You may also lack a QE (not sure if that's checked on the server).

What is a QE?

I'm so sorry, the app version was not set right because I was not using the correct version of instagram-private-api. So your commit did solve the bug. Thanks @Nerixyz !