Commit c1687b73 authored by JC Brand's avatar JC Brand

Merge pull request #79 from chenhouwu/0.6.x

fix: if fullname does not exist, an exception will report about *split* ...
parents 22a68d34 639bdeb6
...@@ -403,10 +403,12 @@ ...@@ -403,10 +403,12 @@
this.messages = new converse.Messages(); this.messages = new converse.Messages();
this.messages.localStorage = new Backbone.LocalStorage( this.messages.localStorage = new Backbone.LocalStorage(
hex_sha1('converse.messages'+this.get('jid')+converse.bare_jid)); hex_sha1('converse.messages'+this.get('jid')+converse.bare_jid));
var fullname = this.get('fullname');
fullname = _.isEmpty(fullname)? this.get('jid'): fullname;
this.set({ this.set({
'user_id' : Strophe.getNodeFromJid(this.get('jid')), 'user_id' : Strophe.getNodeFromJid(this.get('jid')),
'box_id' : hex_sha1(this.get('jid')), 'box_id' : hex_sha1(this.get('jid')),
'fullname' : this.get('fullname'), 'fullname' : fullname,
'url': this.get('url'), 'url': this.get('url'),
'image_type': this.get('image_type'), 'image_type': this.get('image_type'),
'image': this.get('image') 'image': this.get('image')
...@@ -420,9 +422,11 @@ ...@@ -420,9 +422,11 @@
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)? '': fullname).split(' ')[0];
if (!body) { if (!body) {
if (composing.length) { if (composing.length) {
this.messages.add({ this.messages.add({
...@@ -603,8 +607,10 @@ ...@@ -603,8 +607,10 @@
converse.connection.send(message); converse.connection.send(message);
converse.connection.send(forwarded); converse.connection.send(forwarded);
// Add the new message // Add the new message
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
...@@ -646,6 +652,7 @@ ...@@ -646,6 +652,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)? '': fullname;
if (this.$el.is(':visible')) { if (this.$el.is(':visible')) {
if (chat_status === 'offline') { if (chat_status === 'offline') {
this.insertStatusNotification(fullname+' '+'has gone offline'); this.insertStatusNotification(fullname+' '+'has gone offline');
...@@ -1865,10 +1872,12 @@ ...@@ -1865,10 +1872,12 @@
} }
if (!chatbox) { if (!chatbox) {
var fullname = roster_item.get('fullname');
fullname = _.isEmpty(fullname)?jid: fullname;
chatbox = this.create({ chatbox = this.create({
'id': partner_jid, 'id': partner_jid,
'jid': partner_jid, 'jid': partner_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')
......
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