Set id
on MUC join presence
This is necessary for the Bifrost Matrix-XMPP bridge
This commit is contained in:
parent
72eb9d9595
commit
46a5a64dda
@ -14,7 +14,7 @@ import { computeAffiliationsDelta, setAffiliations, getAffiliationList } from '
|
||||
import { getOpenPromise } from '@converse/openpromise';
|
||||
import { initStorage } from '@converse/headless/utils/storage.js';
|
||||
import { isArchived, getMediaURLsMetadata } from '@converse/headless/shared/parsers';
|
||||
import { isUniView } from '@converse/headless/utils/core.js';
|
||||
import { isUniView, getUniqueId } from '@converse/headless/utils/core.js';
|
||||
import { parseMUCMessage, parseMUCPresence } from './parsers.js';
|
||||
import { sendMarker } from '@converse/headless/shared/actions';
|
||||
|
||||
@ -188,6 +188,7 @@ const ChatRoomMixin = {
|
||||
|
||||
async constructPresence (password) {
|
||||
let stanza = $pres({
|
||||
'id': getUniqueId(),
|
||||
'from': _converse.connection.jid,
|
||||
'to': this.getRoomJIDAndNick()
|
||||
}).c('x', { 'xmlns': Strophe.NS.MUC })
|
||||
@ -732,7 +733,7 @@ const ChatRoomMixin = {
|
||||
}
|
||||
const editable = message.get('editable');
|
||||
const stanza = $msg({
|
||||
'id': u.getUniqueId(),
|
||||
'id': getUniqueId(),
|
||||
'to': this.get('jid'),
|
||||
'type': 'groupchat'
|
||||
})
|
||||
@ -980,7 +981,7 @@ const ChatRoomMixin = {
|
||||
if (attrs?.body) {
|
||||
[text, references] = this.parseTextForReferences(attrs.body);
|
||||
}
|
||||
const origin_id = u.getUniqueId();
|
||||
const origin_id = getUniqueId();
|
||||
const body = text ? u.httpToGeoUri(u.shortnamesToUnicode(text), _converse) : undefined;
|
||||
return Object.assign({}, attrs, {
|
||||
body,
|
||||
@ -1073,7 +1074,7 @@ const ChatRoomMixin = {
|
||||
const invitation = $msg({
|
||||
'from': _converse.connection.jid,
|
||||
'to': recipient,
|
||||
'id': u.getUniqueId()
|
||||
'id': getUniqueId()
|
||||
}).c('x', attrs);
|
||||
api.send(invitation);
|
||||
/**
|
||||
@ -1424,9 +1425,9 @@ const ChatRoomMixin = {
|
||||
const jid = Strophe.getBareJidFromJid(this.get('jid'));
|
||||
api.send(
|
||||
$pres({
|
||||
from: _converse.connection.jid,
|
||||
to: `${jid}/${nick}`,
|
||||
id: u.getUniqueId()
|
||||
'from': _converse.connection.jid,
|
||||
'to': `${jid}/${nick}`,
|
||||
'id': getUniqueId()
|
||||
}).tree()
|
||||
)
|
||||
},
|
||||
|
@ -85,7 +85,7 @@ describe("Groupchats", function () {
|
||||
const pres = await u.waitUntil(
|
||||
() => sent_stanzas.slice(index).filter(s => s.nodeName === 'presence').pop());
|
||||
expect(Strophe.serialize(pres)).toBe(
|
||||
`<presence from="${_converse.jid}" to="coven@chat.shakespeare.lit/romeo" xmlns="jabber:client">`+
|
||||
`<presence from="${_converse.jid}" id="${pres.getAttribute('id')}" to="coven@chat.shakespeare.lit/romeo" xmlns="jabber:client">`+
|
||||
`<x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x>`+
|
||||
`<c hash="sha-1" node="https://conversejs.org" ver="TfHz9vOOfqIG0Z9lW5CuPaWGnrQ=" xmlns="http://jabber.org/protocol/caps"/>`+
|
||||
`</presence>`);
|
||||
|
@ -433,7 +433,7 @@ u.placeCaretAtEnd = function (textarea) {
|
||||
this.scrollTop = 999999;
|
||||
};
|
||||
|
||||
u.getUniqueId = function (suffix) {
|
||||
export function getUniqueId (suffix) {
|
||||
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : r & 0x3 | 0x8;
|
||||
@ -574,5 +574,6 @@ export function decodeHTMLEntities (str) {
|
||||
}
|
||||
|
||||
export default Object.assign({
|
||||
isEmptyMessage
|
||||
isEmptyMessage,
|
||||
getUniqueId
|
||||
}, u);
|
||||
|
Loading…
Reference in New Issue
Block a user