Переглянути джерело

MUC: Send XEP-0333 markers with the MUC stanza id

See: https://xmpp.org/extensions/xep-0333.html#rules-muc
JC Brand 4 роки тому
батько
коміт
e8eea6324e
2 змінених файлів з 21 додано та 0 видалено
  1. 1 0
      CHANGES.md
  2. 20 0
      src/headless/plugins/muc/muc.js

+ 1 - 0
CHANGES.md

@@ -10,6 +10,7 @@
 - File structure reordering: All plugins are now in `./plugins` folders.
 - File structure reordering: All plugins are now in `./plugins` folders.
 - New configuration setting: [show_tab_notifications](https://conversejs.org/docs/html/configuration.html#show-tab-notifications)
 - New configuration setting: [show_tab_notifications](https://conversejs.org/docs/html/configuration.html#show-tab-notifications)
 - New configuration setting: [muc_clear_messages_on_leave](https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave)
 - New configuration setting: [muc_clear_messages_on_leave](https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave)
+- Use the MUC stanza id when sending XEP-0333 markers
 
 
 ### Breaking Changes
 ### Breaking Changes
 
 

+ 20 - 0
src/headless/plugins/muc/muc.js

@@ -178,6 +178,26 @@ const ChatRoomMixin = {
         }
         }
     },
     },
 
 
+    /**
+     * Given the passed in MUC message, send a XEP-0333 chat marker.
+     * @param { _converse.MUCMessage } msg
+     * @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
+     * @param { Boolean } force - Whether a marker should be sent for the
+     *  message, even if it didn't include a `markable` element.
+     */
+    sendMarkerForMessage (msg, type='displayed', force=false) {
+        if (!msg) return;
+        if (msg?.get('is_markable') || force) {
+            const id = msg.get(`stanza_id ${this.get('jid')}`);
+            if (!id) {
+                log.error(`Can't send marker for message without stanza ID: ${msg}`);
+                return;
+            }
+            const from_jid = Strophe.getBareJidFromJid(msg.get('from'));
+            this.sendMarker(from_jid, id, type, msg.get('type'));
+        }
+    },
+
     /**
     /**
      * Handler that gets called when the 'hidden' flag is toggled.
      * Handler that gets called when the 'hidden' flag is toggled.
      * @private
      * @private