fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Parsing of "Buddylist Overlay"

Open madsmtm opened this issue 6 years ago • 6 comments

In _parseMessage, you will recieve a lot of data with the type buddylist_overlay. Sample msg:

{
  "seq": 50,
  "t": "msg",
  "u": 1234567890,
  "ms": [
    {
      "type": "buddylist_overlay",
      "overlay": {
        "1234567890": {
          "a": 2,
          "c": 4170,
          "s": "push",
          "vc": 74,
          "la": 1518985361
        }
      }
    }
  ]
}

The 'a' (activeness?) value appears in two (and maybe more?) states: 0 and 2, where 0 means offline and 2 means online. The 'la' (last active?) value indicates the timestamp

This can be used to know when users become online or when they go offline (in real time, compared to onChatTimestamp, which only recieves these updates once in a while).

If anybody can figure out what the c, s or vc values could mean, please let me know (!), otherwise I'll probably make another onX function at some point.

madsmtm avatar Feb 18 '18 21:02 madsmtm

Hello,

It looks like the NodeJS implementation does not have much more information than we have (https://github.com/Schmavery/facebook-chat-api/blob/master/DOCS.md#listen)

I tried to understand the values of c, s or vc but nothing obvious. s looks always 'push', c is not always defined, vc is often 74. Maybe we can get information about those values in Facebook js, but it's not easy.

Do you received those messages without opening your browser? Even if markAlive is True I need to open my browser to receive buddylist_overlay messages, you too?

2FWAH avatar Mar 20 '18 10:03 2FWAH

I can't confirm whether or not I can recieve these messages without opening Facebook in my browser, yet. If it's the case, though, then that's really wierd...

EDIT: I'm starting to think you're right about it...

Warning: There's a lot of complicated code here, if you don't understand boolean operators.

Anyways, I did some digging into the code on https://www.facebook.com, it seems like c and s is unused, and I found that vc gets saved, and can later be retrieved per user, with a function they called c('PresenceStatus').getCapabilities. It's only used one place, a function they called c('FBRTCAvailability').isCallable:

function(j) { // j is the user ID here
    var k = c("PresenceStatus").getCapabilities(j); // Gets the `vc` value of the user
    l = c("ChannelConstants").CAPABILITY_VOIP_INTEROP; // this is 8
    return !!(k & l);
}

Basically, what I found is that if vc is used as some sort of C-style boolean flag-holder-variable: If vc & 8, then Facebook say's the person is callable

I've currently only seen vc be 0, 8, 10 and 74. They have the following bit-values:

74: 001001010
10: 00001010
8: 00001000
0: 00000000

Which tells me that there are at least two other boolean values worth looking into that vc gives us: vc & 2 and vc & 64.

I haven't figured out yet what they could mean.

madsmtm avatar Mar 20 '18 14:03 madsmtm

I also confirmed that la means last active, and that the a value corresponds to the following constants:

class X:
    OFFLINE = 0
    IDLE = 1
    ACTIVE = 2
    MOBILE = 3

Though I've still only seen it being 0 or 2

madsmtm avatar Mar 20 '18 15:03 madsmtm

Really strange, the reception of 'buddylist_overlay' messages ends few minutes after closing browser... onChatTimestamp still works (with markAlive=True only). JS probability take care of doing some kind of ping (in addition of GET to /active_ping) to maintain 'buddylist_overlay' messages.

Good find for the meaning of 'a' :+1: Only 0 or 2 for me too.

vc could be Voice Capabilities, and the number could indicate which codecs are available (depending of platform, application version...). It's just an hypothesis.

2FWAH avatar Mar 20 '18 16:03 2FWAH

I let my client run for the day, and after a little over 400 buddylist_overlay-messages, I got the following different values for c: [None, 8, 10, 74, 2048, 2056, 2122, 4106, 4170, 4186, 8192, 8202, 8208, 8266, 8282, 32842, 36954]

EDIT: Just for the record, then I got the following counts for the different values of c:

{8192: 18, 2048: 6, 8266: 2, 74: 94, 8: 54, 4170: 44, 10: 10, 8282: 6, None: 103, 36954: 5, 8208: 8, 2056: 28, 4106: 1, 2122: 15, 4186: 33, 32842: 2, 8202: 2}

And for the different values of vc:

{0: 135, 8: 82, 74: 201, 10: 13}

madsmtm avatar Mar 20 '18 22:03 madsmtm

#273 adds basic support for Buddylist Overlay messages. c, s and vc are not considered (useful?) Messages end when browser is closed, I'm still trying a solution for that...

2FWAH avatar Mar 23 '18 18:03 2FWAH