|
|
@ -727,6 +727,16 @@ MessageReceiver.prototype.extend({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return p.then(() =>
|
|
|
|
return p.then(() =>
|
|
|
|
this.processDecrypted(envelope, msg, this.number).then(message => {
|
|
|
|
this.processDecrypted(envelope, msg, this.number).then(message => {
|
|
|
|
|
|
|
|
const groupId = message.group && message.group.id;
|
|
|
|
|
|
|
|
if (groupId && this.isGroupBlocked(groupId)) {
|
|
|
|
|
|
|
|
window.log.warn(
|
|
|
|
|
|
|
|
`Message ${this.getEnvelopeId(
|
|
|
|
|
|
|
|
envelope
|
|
|
|
|
|
|
|
)} ignored; destined for blocked group`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return this.removeFromCache(envelope);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ev = new Event('sent');
|
|
|
|
const ev = new Event('sent');
|
|
|
|
ev.confirm = this.removeFromCache.bind(this, envelope);
|
|
|
|
ev.confirm = this.removeFromCache.bind(this, envelope);
|
|
|
|
ev.data = {
|
|
|
|
ev.data = {
|
|
|
@ -751,6 +761,16 @@ MessageReceiver.prototype.extend({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return p.then(() =>
|
|
|
|
return p.then(() =>
|
|
|
|
this.processDecrypted(envelope, msg, envelope.source).then(message => {
|
|
|
|
this.processDecrypted(envelope, msg, envelope.source).then(message => {
|
|
|
|
|
|
|
|
const groupId = message.group && message.group.id;
|
|
|
|
|
|
|
|
if (groupId && this.isGroupBlocked(groupId)) {
|
|
|
|
|
|
|
|
window.log.warn(
|
|
|
|
|
|
|
|
`Message ${this.getEnvelopeId(
|
|
|
|
|
|
|
|
envelope
|
|
|
|
|
|
|
|
)} ignored; destined for blocked group`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return this.removeFromCache(envelope);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ev = new Event('message');
|
|
|
|
const ev = new Event('message');
|
|
|
|
ev.confirm = this.removeFromCache.bind(this, envelope);
|
|
|
|
ev.confirm = this.removeFromCache.bind(this, envelope);
|
|
|
|
ev.data = {
|
|
|
|
ev.data = {
|
|
|
@ -991,10 +1011,22 @@ MessageReceiver.prototype.extend({
|
|
|
|
handleBlocked(envelope, blocked) {
|
|
|
|
handleBlocked(envelope, blocked) {
|
|
|
|
window.log.info('Setting these numbers as blocked:', blocked.numbers);
|
|
|
|
window.log.info('Setting these numbers as blocked:', blocked.numbers);
|
|
|
|
textsecure.storage.put('blocked', blocked.numbers);
|
|
|
|
textsecure.storage.put('blocked', blocked.numbers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const groupIds = _.map(blocked.groupIds, groupId => groupId.toBinary());
|
|
|
|
|
|
|
|
window.log.info(
|
|
|
|
|
|
|
|
'Setting these groups as blocked:',
|
|
|
|
|
|
|
|
groupIds.map(groupId => `group(${groupId})`)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
textsecure.storage.put('blocked-groups', groupIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.removeFromCache(envelope);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
isBlocked(number) {
|
|
|
|
isBlocked(number) {
|
|
|
|
return textsecure.storage.get('blocked', []).indexOf(number) >= 0;
|
|
|
|
return textsecure.storage.get('blocked', []).indexOf(number) >= 0;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
isGroupBlocked(groupId) {
|
|
|
|
|
|
|
|
return textsecure.storage.get('blocked-groups', []).indexOf(groupId) >= 0;
|
|
|
|
|
|
|
|
},
|
|
|
|
handleAttachment(attachment) {
|
|
|
|
handleAttachment(attachment) {
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
attachment.id = attachment.id.toString();
|
|
|
|
attachment.id = attachment.id.toString();
|
|
|
|