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