Fix edit message in Note to Self

This commit is contained in:
Fedor Indutny 2023-05-31 08:54:45 -07:00 committed by GitHub
parent 557b86f52e
commit b705609341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View file

@ -221,7 +221,7 @@ export async function sendNormalMessage(
// or sending a story to a group where all other users don't have the stories
// capabilities (effectively a 'lonely group' in the context of stories)
log.info('sending sync message only');
const dataMessage = await messaging.getDataMessage({
const dataMessage = await messaging.getDataOrEditMessage({
attachments,
body,
bodyRanges,

View file

@ -168,7 +168,7 @@ export async function sendReaction(
if (recipientIdentifiersWithoutMe.length === 0) {
log.info('sending sync reaction message only');
const dataMessage = await messaging.getDataMessage({
const dataMessage = await messaging.getDataOrEditMessage({
attachments: [],
expireTimer,
groupV2: conversation.getGroupV2Info({

View file

@ -566,10 +566,6 @@ class Message {
this.dataMessage = proto;
return proto;
}
encode(): Uint8Array {
return Proto.DataMessage.encode(this.toProto()).finish();
}
}
type AddPniSignatureMessageToProtoOptionsType = Readonly<{
@ -687,11 +683,21 @@ export default class MessageSender {
return textAttachment;
}
async getDataMessage(
async getDataOrEditMessage(
options: Readonly<MessageOptionsType>
): Promise<Uint8Array> {
const message = await this.getHydratedMessage(options);
return message.encode();
const dataMessage = message.toProto();
if (options.editedMessageTimestamp) {
const editMessage = new Proto.EditMessage();
editMessage.dataMessage = dataMessage;
editMessage.targetSentTimestamp = Long.fromNumber(
options.editedMessageTimestamp
);
return Proto.EditMessage.encode(editMessage).finish();
}
return Proto.DataMessage.encode(dataMessage).finish();
}
async getStoryMessage({