Send edited messages support
Co-authored-by: Fedor Indutnyy <indutny@signal.org>
This commit is contained in:
parent
d380817a44
commit
1f2cde6d04
79 changed files with 2507 additions and 1175 deletions
|
@ -3,7 +3,6 @@
|
|||
|
||||
import type { MessageAttributesType } from '../model-types.d';
|
||||
import type { MessageModel } from '../models/messages';
|
||||
import type { ProcessedDataMessage } from '../textsecure/Types.d';
|
||||
import * as Errors from '../types/errors';
|
||||
import * as log from '../logging/log';
|
||||
import { drop } from '../util/drop';
|
||||
|
@ -12,7 +11,7 @@ import { getContactId } from '../messages/helpers';
|
|||
import { handleEditMessage } from '../util/handleEditMessage';
|
||||
|
||||
export type EditAttributesType = {
|
||||
dataMessage: ProcessedDataMessage;
|
||||
conversationId: string;
|
||||
fromId: string;
|
||||
message: MessageAttributesType;
|
||||
targetSentTimestamp: number;
|
||||
|
@ -29,9 +28,14 @@ export function forMessage(message: MessageModel): Array<EditAttributesType> {
|
|||
});
|
||||
|
||||
if (size(matchingEdits) > 0) {
|
||||
log.info('Edits.forMessage: Found early edit for message');
|
||||
const result = Array.from(matchingEdits);
|
||||
const editsLogIds = result.map(x => x.message.sent_at);
|
||||
log.info(
|
||||
`Edits.forMessage(${message.get('sent_at')}): ` +
|
||||
`Found early edits for message ${editsLogIds.join(', ')}`
|
||||
);
|
||||
filter(matchingEdits, item => edits.delete(item));
|
||||
return Array.from(matchingEdits);
|
||||
return result;
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -64,7 +68,7 @@ export async function onEdit(edit: EditAttributesType): Promise<void> {
|
|||
targetConversation.queueJob('Edits.onEdit', async () => {
|
||||
log.info('Handling edit for', {
|
||||
targetSentTimestamp: edit.targetSentTimestamp,
|
||||
sentAt: edit.dataMessage.timestamp,
|
||||
sentAt: edit.message.timestamp,
|
||||
});
|
||||
|
||||
const messages = await window.Signal.Data.getMessagesBySentAt(
|
||||
|
@ -74,7 +78,7 @@ export async function onEdit(edit: EditAttributesType): Promise<void> {
|
|||
// Verify authorship
|
||||
const targetMessage = messages.find(
|
||||
m =>
|
||||
edit.message.conversationId === m.conversationId &&
|
||||
edit.conversationId === m.conversationId &&
|
||||
edit.fromId === getContactId(m)
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue