From 179f7ef7c65615810805eab7f1a2ed24ffed7c7a Mon Sep 17 00:00:00 2001 From: Dele Olajide <dele@4ng.net> Date: Wed, 29 Apr 2020 19:54:31 +0100 Subject: [PATCH] Send marker when subject and empty body received --- plugins/converse-rai.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/plugins/converse-rai.js b/plugins/converse-rai.js index 20fa970..6522f9e 100644 --- a/plugins/converse-rai.js +++ b/plugins/converse-rai.js @@ -50,7 +50,7 @@ _converse.connection.addHandler(function (message) { message.querySelectorAll('activity').forEach(function (activity) { - if (activity) { + if (activity && activity.getAttribute("xmlns") == "xmpp:prosody.im/protocol/rai") { const jid = activity.innerHTML; _converse.api.trigger('chatRoomActivityIndicators', jid); @@ -62,9 +62,30 @@ } }); + const subject = message.querySelector('subject'); + const body = message.querySelector('body'); + if (subject && !body) sendMarker(message.getAttribute('from'), message.getAttribute('id'), 'received'); + return true; - }, "xmpp:prosody.im/protocol/rai", 'message'); + }, null, 'message', 'groupchat'); + } + + function sendMarker(to_jid, id, type) + { + console.debug("sendMarker", to_jid, id, type); + + const stanza = $msg({ + 'from': _converse.connection.jid, + 'id': Math.random().toString(36).substr(2,9), + 'to': to_jid, + 'type': 'chat' + }).c(type, { + 'xmlns': Strophe.NS.MARKERS, + 'id': id + }); + + _converse.api.send(stanza); } function notifyText(message, title, notifyId, callback) { -- GitLab