Add support for syncing blocked numbers

// FREEBIE
This commit is contained in:
lilia 2016-09-06 17:12:45 -07:00
parent 53f20640af
commit f610233ef6
7 changed files with 56 additions and 2 deletions

View file

@ -38100,7 +38100,10 @@ MessageReceiver.prototype.extend({
// fault, and we should handle them gracefully and tell the
// user they received an invalid message
request.respond(200, 'OK');
this.queueEnvelope(envelope);
if (!this.isBlocked(envelope.source)) {
this.queueEnvelope(envelope);
}
}.bind(this)).catch(function(e) {
request.respond(500, 'Bad encrypted websocket message');
@ -38272,6 +38275,8 @@ MessageReceiver.prototype.extend({
this.handleContacts(syncMessage.contacts);
} else if (syncMessage.groups) {
this.handleGroups(syncMessage.groups);
} else if (syncMessage.blocked) {
this.handleBlocked(syncMessage.blocked);
} else if (syncMessage.request) {
console.log('Got SyncMessage Request');
} else if (syncMessage.read) {
@ -38348,6 +38353,12 @@ MessageReceiver.prototype.extend({
});
});
},
handleBlocked: function(blocked) {
textsecure.storage.put('blocked', blocked.numbers);
},
isBlocked: function(number) {
return textsecure.storage.get('blocked', []).indexOf(number) >= 0;
},
handleAttachment: function(attachment) {
function decryptAttachment(encrypted) {
return textsecure.crypto.decryptAttachment(