From 11b822eaf381e1b841d2c73a01718c8cf43948d8 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 19 Mar 2015 13:49:09 -0700 Subject: [PATCH] Allow unknown groups Save groups even if we've never heard of them. Previously we would fail to save due to a missing 'type' attribute. --- js/models/conversations.js | 6 +++++- js/models/messages.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 4d66f9c7..3f6f8d32 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -180,7 +180,11 @@ }, getTitle: function() { - return this.get('name') || this.get('members') || this.id; + if (this.isPrivate()) { + return this.get('name') || this.id; + } else { + return this.get('name') || 'Unknown group'; + } }, getNumber: function() { diff --git a/js/models/messages.js b/js/models/messages.js index 8a5a387d..b02212eb 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -122,6 +122,10 @@ conversation.fetch().always(function() { if (pushMessageContent.group) { var group_update = {}; + attributes = { + type: 'group', + groupId: pushMessageContent.group.id, + }; if (pushMessageContent.group.type === textsecure.protobuf.PushMessageContent.GroupContext.Type.UPDATE) { attributes = { type : 'group', @@ -138,7 +142,7 @@ } else if (pushMessageContent.group.type === textsecure.protobuf.PushMessageContent.GroupContext.Type.QUIT) { group_update = { left: source }; - attributes = { members: _.without(conversation.get('members'), source) }; + attributes.members = _.without(conversation.get('members'), source); } if (_.keys(group_update).length > 0) {