Commit 4b905406 authored by JC Brand's avatar JC Brand

Fall back to user's JID when fullname not found

parent fc3a0840
...@@ -570,8 +570,9 @@ ...@@ -570,8 +570,9 @@
from = Strophe.getBareJidFromJid($message.attr('from')), from = Strophe.getBareJidFromJid($message.attr('from')),
composing = $message.find('composing'), composing = $message.find('composing'),
delayed = $message.find('delay').length > 0, delayed = $message.find('delay').length > 0,
fullname = (this.get('fullname')||'').split(' ')[0], fullname = this.get('fullname'),
stamp, time, sender; stamp, time, sender;
fullname = (_.isEmpty(fullname)? from: fullname).split(' ')[0];
if (!body) { if (!body) {
if (composing.length) { if (composing.length) {
...@@ -949,8 +950,10 @@ ...@@ -949,8 +950,10 @@
this.model.trigger('showSentOTRMessage', text); this.model.trigger('showSentOTRMessage', text);
} else { } else {
// We only save unencrypted messages. // We only save unencrypted messages.
var fullname = converse.xmppstatus.get('fullname');
fullname = _.isEmpty(fullname)? converse.bare_jid: fullname;
this.model.messages.create({ this.model.messages.create({
fullname: converse.xmppstatus.get('fullname')||converse.bare_jid, fullname: fullname,
sender: 'me', sender: 'me',
time: converse.toISOString(new Date()), time: converse.toISOString(new Date()),
message: text message: text
...@@ -1077,6 +1080,7 @@ ...@@ -1077,6 +1080,7 @@
if (_.has(item.changed, 'chat_status')) { if (_.has(item.changed, 'chat_status')) {
var chat_status = item.get('chat_status'), var chat_status = item.get('chat_status'),
fullname = item.get('fullname'); fullname = item.get('fullname');
fullname = _.isEmpty(fullname)? item.get('jid'): fullname;
if (this.$el.is(':visible')) { if (this.$el.is(':visible')) {
if (chat_status === 'offline') { if (chat_status === 'offline') {
this.showStatusNotification(fullname+' '+'has gone offline'); this.showStatusNotification(fullname+' '+'has gone offline');
...@@ -2281,7 +2285,7 @@ ...@@ -2281,7 +2285,7 @@
}, },
messageReceived: function (message) { messageReceived: function (message) {
var partner_jid, $message = $(message), var buddy_jid, $message = $(message),
message_from = $message.attr('from'); message_from = $message.attr('from');
if (message_from == converse.connection.jid) { if (message_from == converse.connection.jid) {
// FIXME: Forwarded messages should be sent to specific resources, // FIXME: Forwarded messages should be sent to specific resources,
...@@ -2297,33 +2301,36 @@ ...@@ -2297,33 +2301,36 @@
resource, chatbox, roster_item; resource, chatbox, roster_item;
if (from == converse.bare_jid) { if (from == converse.bare_jid) {
// I am the sender, so this must be a forwarded message... // I am the sender, so this must be a forwarded message...
partner_jid = to; buddy_jid = to;
resource = Strophe.getResourceFromJid($message.attr('to')); resource = Strophe.getResourceFromJid($message.attr('to'));
} else { } else {
partner_jid = from; buddy_jid = from;
resource = Strophe.getResourceFromJid(message_from); resource = Strophe.getResourceFromJid(message_from);
} }
chatbox = this.get(partner_jid); chatbox = this.get(buddy_jid);
roster_item = converse.roster.get(partner_jid); roster_item = converse.roster.get(buddy_jid);
if (roster_item === undefined) { if (roster_item === undefined) {
// The buddy was likely removed // The buddy was likely removed
converse.log('Could not get roster item for JID '+partner_jid, 'error'); converse.log('Could not get roster item for JID '+buddy_jid, 'error');
return true; return true;
} }
if (!chatbox) { if (!chatbox) {
var fullname = roster_item.get('fullname');
fullname = _.isEmpty(fullname)? buddy_jid: fullname;
chatbox = this.create({ chatbox = this.create({
'id': partner_jid, 'id': buddy_jid,
'jid': partner_jid, 'jid': buddy_jid,
'fullname': roster_item.get('fullname') || jid, 'fullname': fullname,
'image_type': roster_item.get('image_type'), 'image_type': roster_item.get('image_type'),
'image': roster_item.get('image'), 'image': roster_item.get('image'),
'url': roster_item.get('url') 'url': roster_item.get('url')
}); });
} }
chatbox.messageReceived(message); chatbox.messageReceived(message);
converse.roster.addResource(partner_jid, resource); converse.roster.addResource(buddy_jid, resource);
return true; return true;
} }
}); });
......
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