Skip to content

Commit

Permalink
Merge pull request #1525 from Bilb/fix-sync-1-to-1
Browse files Browse the repository at this point in the history
fix building of sync message from 1-to-1 convo
  • Loading branch information
Bilb authored Mar 1, 2021
2 parents 8e18089 + b8a17bc commit f477527
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions ts/session/messages/outgoing/content/data/ChatMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,16 @@ export class ChatMessage extends DataMessage {
) {
if (
(dataMessage as any).constructor.name !== 'DataMessage' &&
!(dataMessage instanceof DataMessage)
!(dataMessage instanceof SignalService.DataMessage)
) {
throw new Error(
'Tried to build a sync message from something else than a DataMessage'
window.log.warn(
'buildSyncMessage with something else than a DataMessage'
);
}

if (!sentTimestamp || !isNumber(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?.displayName) {
lokiProfile.displayName = dataMessage.profile.displayName;
}
if (dataMessage.profile?.profilePicture) {
lokiProfile.avatarPointer = dataMessage.profile.profilePicture;
}
}

const timestamp = toNumber(sentTimestamp);
const body = dataMessage.body || undefined;
const attachments = (dataMessage.attachments || []).map(attachment => {
Expand All @@ -147,7 +130,6 @@ export class ChatMessage extends DataMessage {
attachments,
body,
quote,
lokiProfile,
preview,
syncTarget,
});
Expand Down

0 comments on commit f477527

Please sign in to comment.