MUC: Don't first check if we're registered before unregistering
The IQ stanza being sent to check was in any case incorrect and it doesn't seem necessary.
This commit is contained in:
parent
39d60f05c3
commit
ff1b6d3adf
@ -1543,8 +1543,16 @@ const ChatRoomMixin = {
|
||||
return identity_el ? identity_el.getAttribute('name') : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Send an IQ stanza to the MUC to register this user's nickname.
|
||||
* This sets the user's affiliation to 'member' (if they weren't affiliated
|
||||
* before) and reserves the nickname for this user, thereby preventing other
|
||||
* users from using it in this MUC.
|
||||
* See https://xmpp.org/extensions/xep-0045.html#register
|
||||
* @private
|
||||
* @method _converse.ChatRoom#registerNickname
|
||||
*/
|
||||
async registerNickname () {
|
||||
// See https://xmpp.org/extensions/xep-0045.html#register
|
||||
const { __ } = _converse;
|
||||
const nick = this.get('nick');
|
||||
const jid = this.get('jid');
|
||||
@ -1593,26 +1601,19 @@ const ChatRoomMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
async unregisterNickname () {
|
||||
const jid = this.get('jid');
|
||||
let iq;
|
||||
try {
|
||||
iq = await api.sendIQ(
|
||||
$iq({
|
||||
'to': jid,
|
||||
'type': 'set'
|
||||
}).c('query', { 'xmlns': Strophe.NS.MUC_REGISTER })
|
||||
);
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
return e;
|
||||
}
|
||||
if (sizzle(`query[xmlns="${Strophe.NS.MUC_REGISTER}"] registered`, iq).pop()) {
|
||||
const iq = $iq({ 'to': jid, 'type': 'set' })
|
||||
/**
|
||||
* Send an IQ stanza to the MUC to unregister this user's nickname.
|
||||
* If the user had a 'member' affiliation, it'll be removed and their
|
||||
* nickname will no longer be reserved and can instead be used (and
|
||||
* registered) by other users.
|
||||
* @private
|
||||
* @method _converse.ChatRoom#unregisterNickname
|
||||
*/
|
||||
unregisterNickname () {
|
||||
const iq = $iq({ 'to': this.get('jid'), 'type': 'set' })
|
||||
.c('query', { 'xmlns': Strophe.NS.MUC_REGISTER })
|
||||
.c('remove');
|
||||
return api.sendIQ(iq).catch(e => log.error(e));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -79,20 +79,6 @@ describe("Chatrooms", function () {
|
||||
|
||||
_converse.connection.IQ_stanzas = [];
|
||||
room.close();
|
||||
stanza = await u.waitUntil(() => _converse.connection.IQ_stanzas.filter(
|
||||
iq => sizzle(`iq[to="${muc_jid}"][type="set"] query[xmlns="jabber:iq:register"]`, iq).length
|
||||
).pop());
|
||||
_converse.connection.IQ_stanzas = [];
|
||||
|
||||
result = $iq({
|
||||
'from': room.get('jid'),
|
||||
'id': stanza.getAttribute('id'),
|
||||
'to': _converse.bare_jid,
|
||||
'type': 'result',
|
||||
}).c('query', {'xmlns': 'jabber:iq:register'})
|
||||
.c('registered').up()
|
||||
.c('username').t('romeo');
|
||||
_converse.connection._dataRecv(mock.createRequest(result));
|
||||
|
||||
stanza = await u.waitUntil(() => _converse.connection.IQ_stanzas.filter(
|
||||
iq => sizzle(`iq[to="${muc_jid}"][type="set"] query[xmlns="jabber:iq:register"]`, iq).length
|
||||
|
Loading…
Reference in New Issue
Block a user