Commit b5c56c83 authored by JC Brand's avatar JC Brand

Add `getFullname` to XMPPStatus model and use that

instead of returning the fullname as fallback in `getNickname`
parent 5f5de90f
......@@ -280,22 +280,10 @@
}
});
await test_utils.openChatRoom(_converse, 'lounge', 'montague.lit', 'romeo');
let stanza = await u.waitUntil(() => _.filter(
IQ_stanzas,
iq => iq.querySelector(
`iq[to="${muc_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop());
// We pretend this is a new room, so no disco info is returned.
/* <iq from="jordie.langen@chat.example.org/converse.js-11659299" to="myroom@conference.chat.example.org" type="get">
* <query xmlns="http://jabber.org/protocol/disco#info"/>
* </iq>
* <iq xmlns="jabber:client" type="error" to="jordie.langen@chat.example.org/converse.js-11659299" from="myroom@conference.chat.example.org">
* <error type="cancel">
* <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
* </error>
* </iq>
*/
const disco_selector = `iq[to="${muc_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`;
const stanza = await u.waitUntil(() => IQ_stanzas.filter(iq => iq.querySelector(disco_selector)).pop());
// We pretend this is a new room, so no disco info is returned.
const features_stanza = $iq({
'from': 'lounge@montague.lit',
'id': stanza.getAttribute('id'),
......@@ -307,40 +295,8 @@
const view = _converse.chatboxviews.get('lounge@montague.lit');
spyOn(view.model, 'join').and.callThrough();
/* <iq to="myroom@conference.chat.example.org"
* from="jordie.langen@chat.example.org/converse.js-11659299"
* type="get">
* <query xmlns="http://jabber.org/protocol/disco#info"
* node="x-roomuser-item"/>
* </iq>
*/
stanza = await u.waitUntil(() => _.filter(
IQ_stanzas,
s => sizzle(`iq[to="${muc_jid}"] query[node="x-roomuser-item"]`, s).length
).pop()
);
expect(Strophe.serialize(stanza)).toBe(
`<iq from="romeo@montague.lit/orchard" id="${stanza.getAttribute("id")}" to="lounge@montague.lit" `+
`type="get" xmlns="jabber:client">`+
`<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`);
/* <iq xmlns="jabber:client" type="error" to="jordie.langen@chat.example.org/converse.js-11659299" from="myroom@conference.chat.example.org">
* <error type="cancel">
* <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
* </error>
* </iq>
*/
const result_stanza = $iq({
'type': 'error',
'id': stanza.getAttribute('id'),
'from': view.model.get('jid'),
'to': _converse.connection.jid
}).c('error', {'type': 'cancel'})
.c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
_converse.connection._dataRecv(test_utils.createRequest(result_stanza));
const input = await u.waitUntil(() => view.el.querySelector('input[name="nick"]'));
await test_utils.waitForReservedNick(_converse, muc_jid, '');
const input = await u.waitUntil(() => view.el.querySelector('input[name="nick"]'), 1000);
expect(view.model.get('connection_status')).toBe(converse.ROOMSTATUS.NICKNAME_REQUIRED);
input.value = 'nicky';
view.el.querySelector('input[type=submit]').click();
......
......@@ -1292,6 +1292,11 @@ _converse.initialize = async function (settings, callback) {
return _converse.nickname;
},
getFullname () {
// Gets overridden in converse-vcard
return '';
},
constructPresence (type, status_message) {
let presence;
type = _.isString(type) ? type : (this.get('status') || _converse.default_state);
......
......@@ -1201,7 +1201,7 @@ converse.plugins.add('converse-muc', {
'xmlns': Strophe.NS.DISCO_INFO,
'node': 'x-roomuser-item'
})
const result = await _converse.api.sendIQ(stanza, null, true);
const result = await _converse.api.sendIQ(stanza, null, false);
if (u.isErrorObject(result)) {
throw result;
}
......
......@@ -294,7 +294,7 @@ converse.plugins.add('converse-roster', {
if (message && message !== "") {
pres.c("status").t(message).up();
}
const nick = _converse.xmppstatus.getNickname();
const nick = _converse.xmppstatus.getNickname() || _converse.xmppstatus.getFullname();
if (nick) {
pres.c('nick', {'xmlns': Strophe.NS.NICK}).t(nick).up();
}
......@@ -473,7 +473,7 @@ converse.plugins.add('converse-roster', {
if (item.getAttribute('action') === 'add') {
_converse.roster.addAndSubscribe(
item.getAttribute('jid'),
_converse.xmppstatus.getNickname()
_converse.xmppstatus.getNickname() || _converse.xmppstatus.getFullname()
);
}
});
......
......@@ -24,10 +24,20 @@ converse.plugins.add('converse-vcard', {
const { _converse } = this.__super__;
const nick = this.__super__.getNickname.apply(this);
if (!nick && _converse.xmppstatus.vcard) {
return _converse.xmppstatus.vcard.get('nickname') || _converse.xmppstatus.vcard.get('fullname');
return _converse.xmppstatus.vcard.get('nickname');
} else {
return nick;
}
},
getFullname (){
const { _converse } = this.__super__;
const fullname = this.__super__.getFullname.apply(this);
if (!fullname && _converse.xmppstatus.vcard) {
return _converse.xmppstatus.vcard.get('fullname');
} else {
return fullname;
}
}
},
......
......@@ -205,10 +205,14 @@
'id': IQ_id,
'from': view.model.get('jid'),
'to': _converse.connection.jid
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info', 'node': 'x-roomuser-item'})
.c('identity', {'category': 'conference', 'name': nick, 'type': 'text'});
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info', 'node': 'x-roomuser-item'});
if (nick) {
stanza.c('identity', {'category': 'conference', 'name': nick, 'type': 'text'});
}
_converse.connection._dataRecv(utils.createRequest(stanza));
return u.waitUntil(() => view.model.get('nick'));
if (nick) {
return u.waitUntil(() => view.model.get('nick'));
}
};
......
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