Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"replied_to_message" field missing for messages on /ig_message_sync #93

Open
motiwalam opened this issue Feb 8, 2022 · 4 comments
Open
Labels
bug Something isn't working Realtime

Comments

@motiwalam
Copy link

When replying to a message, there should be a "replied_to_message" field that is not present when listening with this API.

I know the field should be present because I see it in the browser.

I also know the field is actually missing and not just discarded in the parsing process because I am listening for messages emitted at "/ig_message_sync" (this is also the path the browser listens at) directly through the mqtt client and the field is still absent.

Any ideas on why this field is missing?

@Nerixyz
Copy link
Owner

Nerixyz commented Feb 8, 2022

This might be because the capabilities of the client aren't updated.

@Nerixyz Nerixyz added bug Something isn't working Realtime labels Feb 8, 2022
@motiwalam
Copy link
Author

Can you direct me to as to where I should start on fixing this?

@Nerixyz
Copy link
Owner

Nerixyz commented Feb 8, 2022

There's

  1. client_capabilities here
  2. capabilitiesHeader from the parent library here
  3. And the app constants here

Most of them are probably outdated.

Keep in mind I haven't tinkered that much with instagram lately.

@motiwalam
Copy link
Author

Okay, I've got it working. I'll issue a pull request sometime later, but until then I'll detail the changes I made for anyone else who has this problem.

First, I updated the capabilitiesHeader to be the one used by my app. It is now 3brTv10=.
Then, I updated the app constants to be the one used by my app. These are now:

  • APP_VERSION = '219.0.0.12.117'
  • APP_VERSION_CODE = '346138365'

Now, the real problem is that, given these app constants, the server expects a different authorization system. Cookies are no longer used: instead, the server sends custom headers that contain the relevant information.

Updating the codebase to reflect this change will probably require a lot more changes, but so far, it seems the bare minimum is the following:

  1. change this line to authorization=${this.ig.state.authorization}
  2. change this line to return this.dsUserId;
  3. update this function to include a new if clause for the ig-set-ig-u-ds-user-id header and use its value to set the dsUserId on this.client.state
  4. add a line after this one to throw an error if uid is undefined. This is so the catch statement fires.

I believe that's all. I also changed the BLOKS_VERSION_ID constant but am unsure if that makes a difference.

Needless to say, these are really quite hacky changes, and I will be working on fully updating the codebase. I am not yet fully acquainted with all the code though, so I'd appreciate any pointers you have as to where and how to update everything.

I am also not entirely sure if this is everything needed. Since the cookie jar is now perpetually empty, any other calls to extract something from the cookie jar will result in an error. It hasn't caused a problem in my use cases so far, but I have not done exhaustive testing.

Until then, it seems that, having done this, the message events emitted by the realtime client will now contain the "replied_to_message" field if such a field exists. Presumably, other events will also be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Realtime
Projects
None yet
Development

No branches or pull requests

2 participants