signal-desktop/ts/util/deleteGroupStoryReplyForEveryone.ts

40 lines
1 KiB
TypeScript
Raw Normal View History

2022-11-04 13:22:07 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { DAY } from './durations';
import { sendDeleteForEveryoneMessage } from './sendDeleteForEveryoneMessage';
import { getMessageById } from '../messages/getMessageById';
import * as log from '../logging/log';
export async function deleteGroupStoryReplyForEveryone(
replyMessageId: string
): Promise<void> {
const messageModel = await getMessageById(replyMessageId);
if (!messageModel) {
log.warn(
`deleteStoryReplyForEveryone: No message model found for reply: ${replyMessageId}`
);
return;
}
const timestamp = messageModel.get('timestamp');
const group = messageModel.getConversation();
if (!group) {
log.warn(
`deleteGroupStoryReplyForEveryone: No conversation model found for: ${messageModel.get(
'conversationId'
)}`
);
return;
}
void sendDeleteForEveryoneMessage(group.attributes, {
2022-11-04 13:22:07 +00:00
deleteForEveryoneDuration: DAY,
id: replyMessageId,
timestamp,
});
}