Fix sync message for editMessage

This commit is contained in:
Fedor Indutny 2023-05-11 08:47:41 -07:00 committed by GitHub
parent 22a540f066
commit 9a7f1e86e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -1806,12 +1806,17 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const timestamp =
this.get('editMessageTimestamp') || mainMessageTimestamp;
const encodedContent = isEditedMessage
? {
encodedEditMessage: dataMessage,
}
: {
encodedDataMessage: dataMessage,
};
return handleMessageSend(
messaging.sendSyncMessage({
encodedDataMessage: dataMessage,
editedMessageTimestamp: isEditedMessage
? mainMessageTimestamp
: undefined,
...encodedContent,
timestamp,
destination: conv.get('e164'),
destinationUuid: conv.get('uuid'),

View file

@ -1181,8 +1181,8 @@ export default class MessageSender {
// Note: this is used for sending real messages to your other devices after sending a
// message to others.
async sendSyncMessage({
editedMessageTimestamp,
encodedDataMessage,
encodedEditMessage,
timestamp,
destination,
destinationUuid,
@ -1195,8 +1195,8 @@ export default class MessageSender {
storyMessage,
storyMessageRecipients,
}: Readonly<{
editedMessageTimestamp?: number;
encodedDataMessage?: Uint8Array;
encodedEditMessage?: Uint8Array;
timestamp: number;
destination: string | undefined;
destinationUuid: string | null | undefined;
@ -1214,11 +1214,8 @@ export default class MessageSender {
const sentMessage = new Proto.SyncMessage.Sent();
sentMessage.timestamp = Long.fromNumber(timestamp);
if (editedMessageTimestamp && encodedDataMessage) {
const dataMessage = Proto.DataMessage.decode(encodedDataMessage);
const editMessage = new Proto.EditMessage();
editMessage.dataMessage = dataMessage;
editMessage.targetSentTimestamp = Long.fromNumber(editedMessageTimestamp);
if (encodedEditMessage) {
const editMessage = Proto.EditMessage.decode(encodedEditMessage);
sentMessage.editMessage = editMessage;
} else if (encodedDataMessage) {
const dataMessage = Proto.DataMessage.decode(encodedDataMessage);