processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.06k stars 1.51k forks source link

ejabberd mod_mam and mod_offline implementation clarifications #3986

Closed cmeng-git closed 1 year ago

cmeng-git commented 1 year ago

Before creating a ticket, please consider if this should fit the discussion forum better: https://github.com/processone/ejabberd/discussions

Environment

Configuration (only if needed): grep -Ev '^$|^\s*#' ejabberd.yml

loglevel: 5

  mod_mam:
    db_type: sql
    assume_mam_usage: true
    default: never
    compress_xml: true

  mod_offline:
    db_type: sql 
    access_max_user_messages: max_user_offline_messages
    use_mam_for_storage: false

Errors from error.log/crash.log

No errors

Bug description / Features Clarifications

ejabberd configuration setting for mod_mam and mod_offline are shown as above.

  1. It is found that mod__mam#assume_mam_usage: true, always override mod_offline#use_mam_for_storage: false. I believe this is intended implementation.

  2. With mod__mam#assume_mam_usage: true. aTalk implementation allows user to disable mam on server via the following attached stanzas. However this created a problem, as no further offline messages are sent to this user, since all the offline messages are not saved in mam archive db. Should ejabberd still consider 'XEP-0160: Best Practices for Handling Offline Messages' implementation under this case?

  3. After changing mod__mam#assume_mam_usage: false; Found that ejabberd still not sending the offline messages when user goes online. The offline messages can only be retrieved via mamQuery.

Correction to #3: This applies to CC messages only. Normal offline messages are sent by ejabberd server as expected.

// ============ disable mam ============= 
2023-02-04 08:20:21.604 26279-26467/org.atalk.android D/SMACK: SENT (0): 
    <iq id='D3VN2-81' type='get'>
      <prefs xmlns='urn:xmpp:mam:2'/>
    </iq>
2023-02-04 08:20:21.614 26279-26468/org.atalk.android D/SMACK: RECV (0): 
    <iq xml:lang='en-GB' to='swordfish@atalk.sytes.net/atalk' from='swordfish@atalk.sytes.net' type='result' id='D3VN2-81'>
      <prefs default='always' xmlns='urn:xmpp:mam:2'>
        <always/>
        <never/>
      </prefs>
    </iq>
2023-02-04 08:20:21.617 26279-26467/org.atalk.android D/SMACK: SENT (0): 
    <iq id='D3VN2-83' type='set'>
      <prefs xmlns='urn:xmpp:mam:2' default='never'>
        <always>
        </always>
        <never>
        </never>
      </prefs>
    </iq>
2023-02-04 08:20:21.637 26279-26468/org.atalk.android D/SMACK: RECV (0): 
    <iq xml:lang='en-GB' to='swordfish@atalk.sytes.net/atalk' from='swordfish@atalk.sytes.net' type='result' id='D3VN2-83'>
      <prefs default='never' xmlns='urn:xmpp:mam:2'>
        <always/>
        <never/>
      </prefs>
    </iq>
badlop commented 1 year ago
  1. It is found that mod__mam#assume_mam_usage: true, always override mod_offline#use_mam_for_storage: false. I believe this is intended implementation.

I have a recent Erlang, and can't compile ejabberd 20.12 now. But I tried with ejabberd 23.01, and this is what I see:

  1. I configure ejabberd 23.01 like you do,
  2. register two accounts,
  3. login to first account using Tkabber (it doesn't support MAM, so it doesn't change MAM user settings at all),
  4. firs account sends 4 messages to second account.
  5. I see in spool Mysql table that the four messages are stored.
  6. When second account logins, it receives the four messages.
cmeng-git commented 1 year ago

Have upgraded aTalk test server to ejabberd 23.01. Yes, it works for the offline messages; it is also independent of the client MAM enable state i.e. set MAM default to always or never.

Other observations: If the recipient has set up two devices for the same account/Jid but with different resources. Found that ejabberd server only send the offline messages to the very first device that goes online. i.e. the same offline messages will not deliver to the second device that goes online after that.

licaon-kter commented 1 year ago

only send the offline messages to the very first device that goes online

Think this is an Offline spec limitation, and one of the reasons why MAM was needed.

cmeng-git commented 1 year ago

Thanks for the clarification. Yes, aTalk is able to receive the offline messages via mamQuery with no problem.

badlop commented 1 year ago

Hi, are any of those doubts still relevant? Otherwise, can this issue get closed?

cmeng-git commented 1 year ago

Will close it.

cmeng-git commented 1 year ago

@

cmeng-git commented 1 year ago

All issues closed