diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index e2c8d09a4..c08a0df60 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -93,8 +93,7 @@ export function isMessageEmpty(message: SignalService.DataMessage) { return ( !flags && - // FIXME remove this hack to drop auto friend requests messages in a few weeks 15/07/2020 - isBodyEmpty(body) && + isEmpty(body) && isEmpty(attachments) && isEmpty(group) && isEmpty(quote) && @@ -104,8 +103,21 @@ export function isMessageEmpty(message: SignalService.DataMessage) { ); } -function isBodyEmpty(body: string) { - return isEmpty(body); +/** + * Incoming sogs messages without reaction must be dropped when they are empty, so we had to separate this function and `isMessageEmpty` + */ +export function isMessageEmptyNoReaction(message: SignalService.DataMessage) { + const { flags, body, attachments, group, quote, preview, openGroupInvitation } = message; + + return ( + !flags && + isEmpty(body) && + isEmpty(attachments) && + isEmpty(group) && + isEmpty(quote) && + isEmpty(preview) && + isEmpty(openGroupInvitation) + ); } export function cleanIncomingDataMessage( diff --git a/ts/receiver/opengroup.ts b/ts/receiver/opengroup.ts index 2837bb988..524f3e111 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, isMessageEmpty } from './dataMessage'; +import { cleanIncomingDataMessage, isMessageEmptyNoReaction } from './dataMessage'; import { handleMessageJob, toRegularMessage } from './queuedJob'; export const handleOpenGroupV4Message = async ( @@ -63,7 +63,7 @@ const handleOpenGroupMessage = async ( return; } - if (isMessageEmpty(idataMessage as SignalService.DataMessage)) { + if (isMessageEmptyNoReaction(idataMessage as SignalService.DataMessage)) { // empty message, drop it window.log.info('received an empty message for sogs'); return;