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

Messages sent through Lightspeed clients intermittently fail to parse #78

Closed
Coffeeist opened this issue May 1, 2021 · 1 comment
Closed

Comments

@Coffeeist
Copy link

Coffeeist commented May 1, 2021

Related to this issue from Miscord - noting here as it seems to be handled within this codebase.

Lightspeed clients - iOS per the linked issue as well as facebook.com/messenger desktop browser site on my side at the least - appear to add some randomized gibberish in front of message data, causing message parsing to fail:

Error while parsing the following message: (�9hjaimLxSMet4EwK36vf9A�{"deltas":[{"deltaNewMessage":{"messageMetadata":{"threadKey":{"threadFbId":1503335003032641},"messageId":"mid.$gAAVXRnTVjEF_V0jSTF5JgOIPszg1","offlineThreadingId":6794103221279471669,"actorFbId":1636270833,"timestamp":1619840436812,"shouldBuzzDevice":true,"tags":["source:chat:light_speed","app_id:2220391788200892"],"threadReadStateEffect":2,"skipBumpThread":false,"cid":{"conversationFbid":1503335003032641}},"body":"test","attachments":[]}}],"firstDeltaSeqId":265093,"lastIssuedSeqId":265093,"queueEntityId":100034260730370} Error while parsing the following message: (�9hjaimLxSMet4EwK36vf9A�

This seems to be randomized such that it does not always insert problematic characters, as it does work fine more often than not in my experience.

Suggestion for a fix:
It seems that the actual data after after the gibberish string consistently starts with {"deltas": - as such I wonder if cutting out everything before {"deltas": would resolve the issue. In my head this would be something like:
ms = ((ms.indexOf('{"deltas"') > 0) ? ms.substr(ms.indexOf('{"deltas"')) : ms) right above here https://github.com/ChatPlug/libfb-js/blob/master/src/Client.ts#L312

Will test myself if I get a chance

@Coffeeist
Copy link
Author

Coffeeist commented May 23, 2021

Can't add a branch/PR so I made a gist of /src/Client.ts with the added line, highlighted here:
https://gist.github.com/Coffeeist/593468fe22dfe6d4ba8a94296ec32c96#file-clients-ts-L312

Tested with multiple users (lightspeed to confirm fix, non lightspeed to regression test) without issue in a bridged group of around 20 people

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants