Don't send to blocked users

This commit is contained in:
Scott Nonnenberg 2022-02-24 18:40:56 -08:00 committed by GitHub
parent de942e1af2
commit fc62fd4564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 5 deletions

View File

@ -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 {

View File

@ -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,

View File

@ -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,

View File

@ -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({

View File

@ -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,

View File

@ -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({

View File

@ -90,6 +90,12 @@ export class SingleProtoJobQueue extends JobQueue<SingleProtoJobData> {
);
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, {

View File

@ -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;
}

View File

@ -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);