fix updates of message on message syncing

pull/1495/head
Audric Ackermann 5 years ago
parent 5ab3680903
commit 58cc6551e5

@ -1055,6 +1055,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
throw new Error('Cannot trigger syncMessage with unknown convo.'); throw new Error('Cannot trigger syncMessage with unknown convo.');
} }
const syncMessage = ChatMessage.buildSyncMessage( const syncMessage = ChatMessage.buildSyncMessage(
this.id,
dataMessage, dataMessage,
conversation.id, conversation.id,
sentTimestamp sentTimestamp

@ -91,19 +91,13 @@ 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
const lokiProfile: any = {
profileKey: new Uint8Array(
(dataMessage.profileKey as any).toArrayBuffer()
),
};
if ( if (
(dataMessage as any)?.$type?.name !== 'DataMessage' && (dataMessage as any).constructor.name !== 'DataMessage' &&
!(dataMessage instanceof DataMessage) !(dataMessage instanceof DataMessage)
) { ) {
throw new Error( throw new Error(
@ -114,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) {
@ -141,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