michalgrzegorczyk-dev
michalgrzegorczyk-dev

Reputation: 61

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

Upvotes: 1

Views: 348

Answers (1)

Badlop
Badlop

Reputation: 4120

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='[email protected]' 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='[email protected]'>
  <result id='1652698091920538'
    queryid='f28'
    xmlns='urn:xmpp:mam:2'>
    <forwarded xmlns='urn:xmpp:forward:0'>
      <message xml:lang='es'
    from='[email protected]/admin'
    type='groupchat'
    id='44:501539'
    xmlns='jabber:client'>
        <archived by='[email protected]'
    id='1652698091920538'
    xmlns='urn:xmpp:mam:tmp'/>
        <stanza-id by='[email protected]'
    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.

Upvotes: 1

Related Questions