Commit 0bd96bbc authored by JC Brand's avatar JC Brand

Bugfix. Don't set xmppstatus' `jid` to null

parent 5278e4fe
...@@ -1477,8 +1477,13 @@ ...@@ -1477,8 +1477,13 @@
this.connfeedback = new this.ConnectionFeedback(); this.connfeedback = new this.ConnectionFeedback();
this.XMPPStatus = Backbone.Model.extend({ this.XMPPStatus = Backbone.Model.extend({
defaults: {
"status": _converse.default_state defaults () {
return {
"status": _converse.default_state,
"jid": _converse.bare_jid,
"vcard_updated": null
}
}, },
initialize () { initialize () {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
const { Promise, Strophe, _, moment, sizzle } = converse.env; const { Promise, Strophe, _, moment, sizzle } = converse.env;
const u = converse.env.utils;
function onVCardData (_converse, jid, iq, callback) { function onVCardData (_converse, jid, iq, callback) {
...@@ -24,7 +25,7 @@ ...@@ -24,7 +25,7 @@
url = _.get(vcard.querySelector('URL'), 'textContent'), url = _.get(vcard.querySelector('URL'), 'textContent'),
fullname = _.get(vcard.querySelector('FN'), 'textContent'); fullname = _.get(vcard.querySelector('FN'), 'textContent');
if (jid) { if (!u.isSameBareJID(jid, _converse.bare_jid)) {
const contact = _converse.roster.get(jid); const contact = _converse.roster.get(jid);
if (contact) { if (contact) {
contact.save({ contact.save({
...@@ -39,8 +40,7 @@ ...@@ -39,8 +40,7 @@
if (callback) { if (callback) {
callback({ callback({
'stanza': iq, 'stanza': iq,
'jid': jid, 'fullname': fullname,
'fullname': fullname || jid,
'image': img, 'image': img,
'image_type': img_type, 'image_type': img_type,
'url': url 'url': url
...@@ -63,16 +63,14 @@ ...@@ -63,16 +63,14 @@
* (String) jid - The Jabber ID of the user whose VCard * (String) jid - The Jabber ID of the user whose VCard
* is being requested. * is being requested.
*/ */
if (Strophe.getBareJidFromJid(jid) === _converse.bare_jid) { const to = Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
jid = null; // No 'to' attr when getting one's own vCard
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!_converse.use_vcards) { if (!_converse.use_vcards) {
if (resolve) { resolve({'jid': jid}); } if (resolve) { resolve({'jid': jid}); }
} else { } else {
_converse.connection.vcard.get( _converse.connection.vcard.get(
_.partial(onVCardData, _converse, jid, _, resolve), _.partial(onVCardData, _converse, jid, _, resolve),
jid, to,
_.partial(onVCardError, _converse, jid, _, resolve) _.partial(onVCardError, _converse, jid, _, resolve)
); );
} }
...@@ -182,14 +180,12 @@ ...@@ -182,14 +180,12 @@
}); });
_converse.on('statusInitialized', function fetchOwnVCard () { _converse.on('statusInitialized', function fetchOwnVCard () {
if (_.isNil(_converse.xmppstatus.get('fullname'))) { if (_.isNil(_converse.xmppstatus.get('vcard_updated'))) {
_converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain) _converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain)
.then((result) => { .then((result) => {
if (result.supported) { if (result.supported) {
_converse.api.vcard.get(_converse.bare_jid) _converse.api.vcard.get(_converse.bare_jid)
.then((vcard) => { .then((vcard) => _converse.xmppstatus.save(vcard));
_converse.xmppstatus.save(vcard);
});
}}) }})
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); .catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
......
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