Remove unregistered group members

Locally remove unregistered users from group membership lists.

Fixes #989
Related to Whispersystems/Signal-Android#6175
Closes #1052

// FREEBIE
This commit is contained in:
haffenloher 2017-02-06 15:13:04 +01:00 committed by lilia
parent d2ddfc72e4
commit a768b94471
2 changed files with 30 additions and 2 deletions

View file

@ -62,6 +62,19 @@
message.save().then(this.trigger.bind(this,'newmessage', message));
},
addMemberLeft: function(source) {
var timestamp = Date.now();
var message = new Whisper.Message({
conversationId : this.id,
source : source,
type : 'incoming',
sent_at : timestamp,
received_at : timestamp,
group_update : {left: source}
});
message.save().then(this.trigger.bind(this,'newmessage', message));
},
onReadMessage: function(message) {
if (this.messageCollection.get(message.id)) {
this.messageCollection.get(message.id).fetch();

View file

@ -201,21 +201,36 @@
this.sendSyncMessage();
}.bind(this)).catch(function(result) {
var now = Date.now();
var errors;
var conversation = this.getConversation();
this.trigger('done');
if (result.dataMessage) {
this.set({dataMessage: result.dataMessage});
}
if (result instanceof Error) {
this.saveErrors(result);
errors = [result];
this.saveErrors(errors);
} else {
this.saveErrors(result.errors);
errors = result.errors;
this.saveErrors(errors);
if (result.successfulNumbers.length > 0) {
this.set({sent: true, expirationStartTimestamp: now});
this.sendSyncMessage();
}
}
if (conversation.get('type') === 'group') {
errors.forEach(function(e) {
if (e.name === 'UnregisteredUserError') {
textsecure.storage.groups.removeNumber(conversation.id, e.number);
conversation.addMemberLeft(e.number);
conversation.set({
members: _.without(conversation.get('members'), e.number)
});
}
});
}
}.bind(this));
},