diff options
author | Matthieu Saulnier <fantom@fedoraproject.org> | 2023-09-10 11:02:37 +0200 |
---|---|---|
committer | Matthieu Saulnier <fantom@fedoraproject.org> | 2023-09-10 11:02:37 +0200 |
commit | c3d25357d4a61a26609480bf84a67a56d1a17fc3 (patch) | |
tree | 4209832fa639354a1c905ca6d3ca899e889df90e /roles/reverseproxy/files/conversejs/src/headless/shared/actions.js | |
parent | 78a34e844540a6f24a42e49bcc00ce00cd6ec955 (diff) | |
download | playbooks-ansible-c3d25357d4a61a26609480bf84a67a56d1a17fc3.tar.gz playbooks-ansible-c3d25357d4a61a26609480bf84a67a56d1a17fc3.tar.xz playbooks-ansible-c3d25357d4a61a26609480bf84a67a56d1a17fc3.zip |
Add conversejs deployment
Diffstat (limited to 'roles/reverseproxy/files/conversejs/src/headless/shared/actions.js')
-rw-r--r-- | roles/reverseproxy/files/conversejs/src/headless/shared/actions.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/roles/reverseproxy/files/conversejs/src/headless/shared/actions.js b/roles/reverseproxy/files/conversejs/src/headless/shared/actions.js new file mode 100644 index 0000000..f10e2cb --- /dev/null +++ b/roles/reverseproxy/files/conversejs/src/headless/shared/actions.js @@ -0,0 +1,41 @@ +import log from '../log'; +import { Strophe, $msg } from 'strophe.js/src/strophe'; +import { _converse, api, converse } from '@converse/headless/core'; + +const u = converse.env.utils; + +export function rejectMessage (stanza, text) { + // Reject an incoming message by replying with an error message of type "cancel". + api.send( + $msg({ + 'to': stanza.getAttribute('from'), + 'type': 'error', + 'id': stanza.getAttribute('id') + }) + .c('error', { 'type': 'cancel' }) + .c('not-allowed', { xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas' }) + .up() + .c('text', { xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas' }) + .t(text) + ); + log.warn(`Rejecting message stanza with the following reason: ${text}`); + log.warn(stanza); +} + + +/** + * Send out a XEP-0333 chat marker + * @param { String } to_jid + * @param { String } id - The id of the message being marked + * @param { String } type - The marker type + * @param { String } msg_type + */ +export function sendMarker (to_jid, id, type, msg_type) { + const stanza = $msg({ + 'from': _converse.connection.jid, + 'id': u.getUniqueId(), + 'to': to_jid, + 'type': msg_type ? msg_type : 'chat' + }).c(type, {'xmlns': Strophe.NS.MARKERS, 'id': id}); + api.send(stanza); +} |