jdev - 2022-01-28


  1. pep.

    Can somebody crash course getting disco info from accounts in roster? Caps are sent in the directed presence and it's up to the client to iq/get the resource if it wants to know? (also valid for my own other resources?)

  2. Kev

    Correct. Get caps in presence, check against caps cache, if missing disco client, check and shove result in cache.

  3. pep.

    ta

  4. pep.

    What about people not in the roster? I can disco their barejid but I'm not given a fulljid unless they specifically put it in @from?

  5. Zash

    @from on a directed presence? that'll always have their full jid there

  6. jonas’

    @from on any type="available" presence you receive, actually

  7. pep.

    Do I get a directed presence from somebody not in my roster?

  8. jonas’

    only if they explicitly send it to you

  9. pep.

    Do clients do that?

  10. jonas’

    probably not

  11. pep.

    Ok

  12. jonas’

    fulljids are also found in the @from of IQs and messages though

  13. pep.

    So if I don't get a directed presence I'm likely not getting their device capabilities

  14. jonas’

    correct

  15. jonas’

    s/likely/at all/

  16. pep.

    Ok

  17. jonas’

    you'll also never notice when a device goes offline or when their capabilities change

  18. Zash

    if you got directed presence? then the server should send you unavailable when they go offline

  19. jonas’

    Zash, "if I don't get a directed presence"

  20. Zash

    ah

  21. Zash

    well then you are in the dark

  22. goffi

    pep.: you can't disco bare jid if you're not in the roster (see my recent email on standard@ about that).

  23. rubi

    > s/likely/at all/ > I'm at all not getting :P

  24. doge

    How do you usually go about parsing the xmpp stream? You can't just use regular DOM with it can you. Are you supposed to use SAX? But I never understood how people use SAX for anything but the simplest of documents, and from reading XEPs xmpp's structure seems to be far from simple. Any patterns/suggestions?

  25. jonas’

    SAX, and it's not that tricky actually

  26. jonas’

    so in aioxmpp, I structure the XML events directly into python objects representing the stanzas, according to the schema declared by the library and the application.

  27. moparisthebest

    you *can* use a regular DOM parser, with some hax

  28. jonas’

    but there's also a mode where stanzas are written into a DOM

  29. jonas’

    if you have a DOM thing which you can feed with SAX events (lxml has that, for instance; but it can also very easily be built from scratch if you have a DOM manipulation library), then you can use the SAX events to create an individual DOM for each stanza

  30. jonas’

    if you're into the pain of using DOM

  31. moparisthebest

    regardless of parser the biggest thing to be aware of is needing to disable 90% of the things XML can do to just get to the subset XMPP uses

  32. jonas’

    oh yes, ^

  33. jonas’

    otherwise, happy billion laughs

  34. moparisthebest

    depends what you are doing too, I guess a client can probably get by not worrying about it and trusting their server to sanitize for them but meh

  35. Kev

    I typically read with a stream parser, and then construct a pseudo-dom from it.

  36. Zash

    Pretty much how Prosody works too

  37. doge

    Either way seems to take lots of code

  38. doge

    Especially "directly from sax" approach, looking at aioxmpp source

  39. jonas’

    the direct from sax magic is in aioxmpp/xso and aioxmpp/xml.py, everything else is then just schemas (which are really useful no matter which approach) and business logic

  40. jonas’

    https://hg.prosody.im/trunk/file/tip/util/xml.lua this is a simple schema-less sax->dom approach

  41. jonas’

    plus the DOM implementation in https://hg.prosody.im/trunk/file/tip/util/stanza.lua

  42. jonas’

    wouldn't say that this is "a lot of code" :)

  43. jonas’

    (considering the amount of business logic involved with xmpp in general)

  44. Zash

    https://hg.prosody.im/trunk/file/tip/util/xmppstream.lua is the one actually used for parsing xmpp

  45. jonas’

    oh yeah, I meant to link that

  46. Zash

    has some session related logic in there tho

  47. jonas’

    my history failed me

  48. MattJ

    The extra stuff in xmppstream is mostly about stanza size accounting, and associating streams with XMPP sessions

  49. MattJ

    The DOM-building part is the same as util.xml in the first link (at least, it is since a couple of weeks ago... :) )

  50. MattJ

    and yes, it's quite straightforward and I've written equivalent code a bunch of times in a bunch of languages and environments

  51. MattJ

    It's definitely my preferred way of doing things

  52. pep.

    goffi: right, thanks