Schmavery / facebook-chat-api

Unofficial Facebook Chat API for Nodejs
MIT License
1.94k stars 596 forks source link

mentions not working when tag is at offset 0 #857

Open shellmage opened 3 years ago

shellmage commented 3 years ago

this doesn't work

        var msg = {
                body: 'user',
                mentions:
                [{
                        tag: 'user',
                        id: 0000000000,
                }]
        }

while this works just fine

        var msg = {
                body: 'Xuser',
                mentions:
                [{
                        tag: 'user',
                        id: 0000000000,
                }]
        }
shellmage commented 3 years ago

a found that a work-around is to add an empty character like so

        emptyChar = '\u200e'
        var msg = {
                body: emptyChar + 'user',
                mentions:
                [{
                        tag: 'user',
                        id: 0000000000,
                }]
        }

I don't think this is a bug in the API, I checked the handleMentions i couldn't find anything wrong if someone can confirm this is a server-side bug and not and API bug, just add this note to the docs and close the issue.

Schmavery commented 3 years ago

What does the browser client do in this case? or is it impossible to send such a message without the API?

shellmage commented 3 years ago

it works fine on the browser, this edge-case only happens when using the api when the tag is at offset 0, it doesn't get highlighted as if there was no mentions at all

BadAimWeeb commented 3 years ago

this is a server-side bug, because the endpoint that this api used is not being used anymore AFAIK (debugging on both latest Chrome and Firefox version), instead everything was moved to MQTT.

btw facebook is using some weird things called LS (send data in /ls_req, receive data & messages (encrypted inside a F***ING FUNCTION) in /ls_resp)

shellmage commented 3 years ago

yeah, this (PR #858 ) is basically a work-around for this server-side bug, so that the developers can use this API without thinking about it (I personally wasted quite some time trying to figure out what's the problem and how to work-around it while trying to implement an @‎everyone group-chat feature