xmppejabberdmultiuserchat

MUC, XMPP - Unread messages counter, last message


Is it possible without joining to the room to get:

  1. the number of unread messages from MUC? I have seen similar questions ~7 years ago but still didn't find such solution. Or is it possible to get information if there is a unread message?

  2. the last message that was written in the room?

Thanks


Solution

  • Is it possible without joining to the room to get:

    If the MUC room has archiving enabled, anybody can query it as shown in https://xmpp.org/extensions/xep-0313.html#example-5

    For example:

    <iq to='room1@conference.localhost' type='set' id='juliet1'>
      <query xmlns='urn:xmpp:mam:2' queryid='f28' />
    </iq>
    

    The response includes all the room messages:

    <message to='user1@localhost/tka1'
        from='room1@conference.localhost'>
      <result id='1652698091920538'
        queryid='f28'
        xmlns='urn:xmpp:mam:2'>
        <forwarded xmlns='urn:xmpp:forward:0'>
          <message xml:lang='es'
        from='room1@conference.localhost/admin'
        type='groupchat'
        id='44:501539'
        xmlns='jabber:client'>
            <archived by='room1@conference.localhost'
        id='1652698091920538'
        xmlns='urn:xmpp:mam:tmp'/>
            <stanza-id by='room1@conference.localhost'
        id='1652698091920538'
        xmlns='urn:xmpp:sid:0'/>
            <body>mensa 1</body>
          </message>
          <delay from='conference.localhost'
        stamp='2022-05-16T10:48:11.920538Z'
        xmlns='urn:xmpp:delay'/>
        </forwarded>
      </result>
    </message>
    

    the number of unread messages from MUC? I have seen similar questions ~7 years ago but still didn't find such solution. Or is it possible to get information if there is a unread message?

    "Unread" is a concept that only the client knows, not the server. The client must tell the server what was the last message the client has read. Maybe using https://xmpp.org/extensions/xep-0313.html#filter-time

    the last message that was written in the room?

    At a quick look I didn't find anything for that in XEP-0313. If you take a closer look, maybe you find some solution.