diff --git a/ts/SignalProtocolStore.ts b/ts/SignalProtocolStore.ts index c9c507b79..45a8284fe 100644 --- a/ts/SignalProtocolStore.ts +++ b/ts/SignalProtocolStore.ts @@ -1095,7 +1095,7 @@ export class SignalProtocolStore extends EventsMixin { throw new Error('getOpenDevices: this.sessions not yet cached!'); } if (identifiers.length === 0) { - throw new Error('getOpenDevices: No identifiers provided!'); + return { devices: [], emptyIdentifiers: [] }; } try { diff --git a/ts/jobs/helpers/sendDeleteForEveryone.ts b/ts/jobs/helpers/sendDeleteForEveryone.ts index 37b62337a..a1fb1dd7a 100644 --- a/ts/jobs/helpers/sendDeleteForEveryone.ts +++ b/ts/jobs/helpers/sendDeleteForEveryone.ts @@ -123,6 +123,12 @@ export async function sendDeleteForEveryone( ); return; } + if (conversation.isBlocked()) { + log.info( + `conversation ${conversation.idForLogging()} is blocked; refusing to send` + ); + return; + } await wrapWithSyncMessageSend({ conversation, diff --git a/ts/jobs/helpers/sendDirectExpirationTimerUpdate.ts b/ts/jobs/helpers/sendDirectExpirationTimerUpdate.ts index e242f01d1..efd2d5921 100644 --- a/ts/jobs/helpers/sendDirectExpirationTimerUpdate.ts +++ b/ts/jobs/helpers/sendDirectExpirationTimerUpdate.ts @@ -115,6 +115,12 @@ export async function sendDirectExpirationTimerUpdate( ); return; } + if (conversation.isBlocked()) { + log.info( + `conversation ${conversation.idForLogging()} is blocked; refusing to send` + ); + return; + } await wrapWithSyncMessageSend({ conversation, diff --git a/ts/jobs/helpers/sendNormalMessage.ts b/ts/jobs/helpers/sendNormalMessage.ts index b5dd138ee..ea2920143 100644 --- a/ts/jobs/helpers/sendNormalMessage.ts +++ b/ts/jobs/helpers/sendNormalMessage.ts @@ -229,6 +229,13 @@ export async function sendNormalMessage( ]); return; } + if (conversation.isBlocked()) { + log.info( + `conversation ${conversation.idForLogging()} is blocked; refusing to send` + ); + markMessageFailed(message, [new Error('Contact is blocked')]); + return; + } log.info('sending direct message'); innerPromise = window.textsecure.messaging.sendMessageToIdentifier({ diff --git a/ts/jobs/helpers/sendProfileKey.ts b/ts/jobs/helpers/sendProfileKey.ts index 8d429dcbc..3e7cb1b07 100644 --- a/ts/jobs/helpers/sendProfileKey.ts +++ b/ts/jobs/helpers/sendProfileKey.ts @@ -97,6 +97,12 @@ export async function sendProfileKey( ); return; } + if (conversation.isBlocked()) { + log.info( + `conversation ${conversation.idForLogging()} is blocked; refusing to send` + ); + return; + } const proto = await window.textsecure.messaging.getContentMessage({ flags: Proto.DataMessage.Flags.PROFILE_KEY_UPDATE, diff --git a/ts/jobs/helpers/sendReaction.ts b/ts/jobs/helpers/sendReaction.ts index cbfec342e..49097192f 100644 --- a/ts/jobs/helpers/sendReaction.ts +++ b/ts/jobs/helpers/sendReaction.ts @@ -196,6 +196,13 @@ export async function sendReaction( markReactionFailed(message, pendingReaction); return; } + if (conversation.isBlocked()) { + log.info( + `conversation ${conversation.idForLogging()} is blocked; refusing to send` + ); + markReactionFailed(message, pendingReaction); + return; + } log.info('sending direct reaction message'); promise = window.textsecure.messaging.sendMessageToIdentifier({ diff --git a/ts/jobs/singleProtoJobQueue.ts b/ts/jobs/singleProtoJobQueue.ts index 8a0d8bfae..f08b6897c 100644 --- a/ts/jobs/singleProtoJobQueue.ts +++ b/ts/jobs/singleProtoJobQueue.ts @@ -90,6 +90,12 @@ export class SingleProtoJobQueue extends JobQueue { ); return; } + if (conversation.isBlocked()) { + log.info( + `conversation ${conversation.idForLogging()} is blocked; refusing to send` + ); + return; + } const proto = Proto.Content.decode(Bytes.fromBase64(protoBase64)); const options = await getSendOptions(conversation.attributes, { diff --git a/ts/util/getConversationMembers.ts b/ts/util/getConversationMembers.ts index 536444d3d..efb1f7ad9 100644 --- a/ts/util/getConversationMembers.ts +++ b/ts/util/getConversationMembers.ts @@ -27,8 +27,11 @@ export function getConversationMembers( members.map(member => { const conversation = window.ConversationController.get(member.uuid); - // In groups we won't sent to contacts we believe are unregistered - if (conversation && conversation.isUnregistered()) { + // In groups we won't sent to blocked contacts or those we think are unregistered + if ( + conversation && + (conversation.isUnregistered() || conversation.isBlocked()) + ) { return null; } @@ -42,8 +45,11 @@ export function getConversationMembers( conversationAttrs.members.map(id => { const conversation = window.ConversationController.get(id); - // In groups we won't send to contacts we believe are unregistered - if (conversation && conversation.isUnregistered()) { + // In groups we won't sent to blocked contacts or those we think are unregistered + if ( + conversation && + (conversation.isUnregistered() || conversation.isBlocked()) + ) { return null; } diff --git a/ts/util/sendReceipts.ts b/ts/util/sendReceipts.ts index eec9b2fbd..f455e99a9 100644 --- a/ts/util/sendReceipts.ts +++ b/ts/util/sendReceipts.ts @@ -103,6 +103,12 @@ export async function sendReceipts({ ); return; } + if (sender.isBlocked()) { + log.info( + `conversation ${sender.idForLogging()} is blocked; refusing to send` + ); + return; + } const sendOptions = await getSendOptions(sender.attributes);