diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index c08a0df60..0e23373e8 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -79,34 +79,23 @@ function cleanAttachments(decrypted: SignalService.DataMessage) { } } -export function isMessageEmpty(message: SignalService.DataMessage) { - const { - flags, - body, - attachments, - group, - quote, - preview, - openGroupInvitation, - reaction, - } = message; +/** + * We separate the isMessageEmpty and the isMessageEmptyExceptReaction, because we + * - sometimes want to drop a message only when it is completely empty, + * - and sometimes only when the message is empty but have a reaction + */ +function isMessageEmpty(message: SignalService.DataMessage) { + const { reaction } = message; - return ( - !flags && - isEmpty(body) && - isEmpty(attachments) && - isEmpty(group) && - isEmpty(quote) && - isEmpty(preview) && - isEmpty(openGroupInvitation) && - isEmpty(reaction) - ); + return isMessageEmptyExceptReaction(message) && isEmpty(reaction); } /** - * Incoming sogs messages without reaction must be dropped when they are empty, so we had to separate this function and `isMessageEmpty` + * We separate the isMessageEmpty and the isMessageEmptyExceptReaction, because we + * - sometimes want to drop a message only when it is completely empty, + * - and sometimes only when the message is empty but have a reaction */ -export function isMessageEmptyNoReaction(message: SignalService.DataMessage) { +export function isMessageEmptyExceptReaction(message: SignalService.DataMessage) { const { flags, body, attachments, group, quote, preview, openGroupInvitation } = message; return ( diff --git a/ts/receiver/opengroup.ts b/ts/receiver/opengroup.ts index 524f3e111..87aeba6dd 100644 --- a/ts/receiver/opengroup.ts +++ b/ts/receiver/opengroup.ts @@ -12,7 +12,7 @@ import { removeMessagePadding } from '../session/crypto/BufferPadding'; import { UserUtils } from '../session/utils'; import { perfEnd, perfStart } from '../session/utils/Performance'; import { fromBase64ToArray } from '../session/utils/String'; -import { cleanIncomingDataMessage, isMessageEmptyNoReaction } from './dataMessage'; +import { cleanIncomingDataMessage, isMessageEmptyExceptReaction } from './dataMessage'; import { handleMessageJob, toRegularMessage } from './queuedJob'; export const handleOpenGroupV4Message = async ( @@ -63,9 +63,11 @@ const handleOpenGroupMessage = async ( return; } - if (isMessageEmptyNoReaction(idataMessage as SignalService.DataMessage)) { + if (isMessageEmptyExceptReaction(idataMessage as SignalService.DataMessage)) { // empty message, drop it - window.log.info('received an empty message for sogs'); + if (!idataMessage.reaction) { + window.log.info('received an empty message for sogs'); + } return; }