Merge pull request #2437 from Bilb/fix-drop-incoming-empty-messages

fix: make sure we drop empty messages from the main sogs pipeline
pull/2448/head
Audric Ackermann 3 years ago committed by GitHub
commit 95c7e6b152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,35 +79,36 @@ 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 isMessageEmptyExceptReaction(message) && isEmpty(reaction);
}
/**
* 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 isMessageEmptyExceptReaction(message: SignalService.DataMessage) {
const { flags, body, attachments, group, quote, preview, openGroupInvitation } = message;
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) &&
isEmpty(preview) &&
isEmpty(openGroupInvitation) &&
isEmpty(reaction)
isEmpty(openGroupInvitation)
);
}
function isBodyEmpty(body: string) {
return isEmpty(body);
}
export function cleanIncomingDataMessage(
rawDataMessage: SignalService.DataMessage,
envelope?: EnvelopePlus

@ -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, isMessageEmptyExceptReaction } from './dataMessage';
import { handleMessageJob, toRegularMessage } from './queuedJob';
export const handleOpenGroupV4Message = async (
@ -63,9 +63,11 @@ const handleOpenGroupMessage = async (
return;
}
if (isMessageEmpty(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;
}

Loading…
Cancel
Save