fix updates of message on message syncing

pull/1515/head
Audric Ackermann 5 years ago
parent a61f5e6814
commit 3f59ce1692
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1300,6 +1300,7 @@
// try catch not to be kept // try catch not to be kept
try { try {
const syncMessage = libsession.Messages.Outgoing.ChatMessage.buildSyncMessage( const syncMessage = libsession.Messages.Outgoing.ChatMessage.buildSyncMessage(
this.id,
dataMessage, dataMessage,
this.getConversation().id, this.getConversation().id,
sentTimestamp sentTimestamp

@ -91,18 +91,15 @@ export class ChatMessage extends DataMessage {
} }
public static buildSyncMessage( public static buildSyncMessage(
dataMessage: SignalService.IDataMessage, identifier: string,
dataMessage: SignalService.DataMessage,
syncTarget: string, syncTarget: string,
sentTimestamp: number sentTimestamp: number
) { ) {
// the dataMessage.profileKey is of type ByteBuffer. We need to make it a Uint8Array if (
const lokiProfile: any = { (dataMessage as any).constructor.name !== 'DataMessage' &&
profileKey: new Uint8Array( !(dataMessage instanceof DataMessage)
(dataMessage.profileKey as any).toArrayBuffer() ) {
),
};
if ((dataMessage as any)?.$type?.name !== 'DataMessage') {
throw new Error( throw new Error(
'Tried to build a sync message from something else than a DataMessage' 'Tried to build a sync message from something else than a DataMessage'
); );
@ -111,6 +108,13 @@ export class ChatMessage extends DataMessage {
if (!sentTimestamp || !isNumber(sentTimestamp)) { if (!sentTimestamp || !isNumber(sentTimestamp)) {
throw new Error('Tried to build a sync message without a sentTimestamp'); throw new Error('Tried to build a sync message without a sentTimestamp');
} }
// the dataMessage.profileKey is of type ByteBuffer. We need to make it a Uint8Array
const lokiProfile: any = {};
if (dataMessage.profileKey?.length) {
lokiProfile.profileKey = new Uint8Array(
(dataMessage.profileKey as any).toArrayBuffer()
);
}
if (dataMessage.profile) { if (dataMessage.profile) {
if (dataMessage.profile?.displayName) { if (dataMessage.profile?.displayName) {
@ -138,6 +142,7 @@ export class ChatMessage extends DataMessage {
const preview = (dataMessage.preview as Array<Preview>) || []; const preview = (dataMessage.preview as Array<Preview>) || [];
return new ChatMessage({ return new ChatMessage({
identifier,
timestamp, timestamp,
attachments, attachments,
body, body,

Loading…
Cancel
Save