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