Commit aa90ebd7 authored by JC Brand's avatar JC Brand

Bugfix. Don't delete JID or resource...

when an affiliation change presence is received.
parent 23455679
...@@ -32702,7 +32702,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -32702,7 +32702,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//# sourceMappingURL=pluggable.js.map //# sourceMappingURL=pluggable.js.map
/***/ }), /***/ }),
/***/ "./node_modules/process/browser.js": /***/ "./node_modules/process/browser.js":
...@@ -67520,11 +67519,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc ...@@ -67520,11 +67519,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc
} }
} }
const jid = Strophe.getBareJidFromJid(data.jid); const jid = data.jid || '';
const attributes = _.extend(data, { const attributes = _.extend(data, {
'jid': jid ? jid : undefined, 'jid': Strophe.getBareJidFromJid(jid) || _.get(occupant, 'attributes.jid'),
'resource': data.jid ? Strophe.getResourceFromJid(data.jid) : undefined 'resource': Strophe.getResourceFromJid(jid) || _.get(occupant, 'attributes.resource')
}); });
if (occupant) { if (occupant) {
This diff is collapsed.
...@@ -4645,14 +4645,13 @@ ...@@ -4645,14 +4645,13 @@
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'trollbox', 'localhost', 'troll'); await test_utils.openAndEnterChatRoom(_converse, 'trollbox', 'localhost', 'troll');
var sent_IQ, IQ_id; let sent_IQ, IQ_id;
var sendIQ = _converse.connection.sendIQ; const sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_IQ = iq; sent_IQ = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
const view = _converse.chatboxviews.get('trollbox@localhost'); const view = _converse.chatboxviews.get('trollbox@localhost');
const textarea = view.el.querySelector('.chat-textarea'); const textarea = view.el.querySelector('.chat-textarea');
textarea.value = 'Hello world'; textarea.value = 'Hello world';
view.onFormSubmitted(new Event('submit')); view.onFormSubmitted(new Event('submit'));
...@@ -4668,6 +4667,48 @@ ...@@ -4668,6 +4667,48 @@
"Your message was not delivered because you're not allowed to send messages in this groupchat."); "Your message was not delivered because you're not allowed to send messages in this groupchat.");
done(); done();
})); }));
it("will see an explanatory message instead of a textarea",
mock.initConverse(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'trollbox', 'localhost', 'troll');
const view = _converse.chatboxviews.get('trollbox@localhost');
let stanza = u.toStanza(`
<presence
from='trollbox@localhost/troll'
to='dummy@localhost/resource'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='moderator'
nick='troll'
role='visitor'/>
<status code='110'/>
</x>
</presence>`);
_converse.connection._dataRecv(test_utils.createRequest(stanza));
let info_msgs = sizzle('.chat-info', view.el);
expect(info_msgs.length).toBe(4);
expect(info_msgs[2].textContent).toBe("troll is no longer a moderator");
expect(info_msgs[3].textContent).toBe("troll has been muted");
stanza = u.toStanza(`
<presence
from='trollbox@localhost/troll'
to='dummy@localhost/resource'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='moderator'
nick='troll'
role='participant'/>
<status code='110'/>
</x>
</presence>`);
_converse.connection._dataRecv(test_utils.createRequest(stanza));
info_msgs = sizzle('.chat-info', view.el);
expect(info_msgs.length).toBe(5);
expect(info_msgs[4].textContent).toBe("troll has been given a voice again");
done();
}));
}); });
}); });
})); }));
...@@ -910,10 +910,10 @@ converse.plugins.add('converse-muc', { ...@@ -910,10 +910,10 @@ converse.plugins.add('converse-muc', {
return; return;
} }
} }
const jid = Strophe.getBareJidFromJid(data.jid); const jid = data.jid || '';
const attributes = _.extend(data, { const attributes = _.extend(data, {
'jid': jid ? jid : undefined, 'jid': Strophe.getBareJidFromJid(jid) || _.get(occupant, 'attributes.jid'),
'resource': data.jid ? Strophe.getResourceFromJid(data.jid) : undefined 'resource': Strophe.getResourceFromJid(jid) || _.get(occupant, 'attributes.resource')
}); });
if (occupant) { if (occupant) {
occupant.save(attributes); occupant.save(attributes);
......
...@@ -30205,7 +30205,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -30205,7 +30205,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//# sourceMappingURL=pluggable.js.map //# sourceMappingURL=pluggable.js.map
/***/ }), /***/ }),
/***/ "./node_modules/process/browser.js": /***/ "./node_modules/process/browser.js":
...@@ -46037,11 +46036,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc ...@@ -46037,11 +46036,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc
} }
} }
const jid = Strophe.getBareJidFromJid(data.jid); const jid = data.jid || '';
const attributes = _.extend(data, { const attributes = _.extend(data, {
'jid': jid ? jid : undefined, 'jid': Strophe.getBareJidFromJid(jid) || _.get(occupant, 'attributes.jid'),
'resource': data.jid ? Strophe.getResourceFromJid(data.jid) : undefined 'resource': Strophe.getResourceFromJid(jid) || _.get(occupant, 'attributes.resource')
}); });
if (occupant) { if (occupant) {
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment