From c419ff9cd25ad4cca559297b92e20331874507dc Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 29 Jun 2020 15:37:27 +1000 Subject: [PATCH] include display name in outgoing messages --- js/models/conversations.js | 26 +++++++++++++++++++ .../outgoing/content/data/ChatMessage.ts | 3 +++ 2 files changed, 29 insertions(+) diff --git a/js/models/conversations.js b/js/models/conversations.js index 6e3dbd861..ea432f57a 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1305,6 +1305,7 @@ }); // FIXME audric add back profileKey + const lokiProfile = this.getOurProfile(); const chatMessage = new libsession.Messages.Outgoing.ChatMessage({ body: messageBody, timestamp: Date.now(), @@ -1312,6 +1313,7 @@ expireTimer, preview, quote, + lokiProfile, }); // Start handle ChatMessages (attachments/quote/preview/body) // FIXME AUDRIC handle attachments, quote, preview, profileKey @@ -2554,6 +2556,30 @@ return this.getNumber(); }, + /** + * Returns + * displayName: string; + * avatarPointer: string; + * profileKey: Uint8Array; + */ + getOurProfile() { + try { + // Secondary devices have their profile stored + // in their primary device's conversation + const ourNumber = window.storage.get('primaryDevicePubKey'); + const ourConversation = window.ConversationController.get(ourNumber); + let profileKey = null; + if (this.get('profileSharing')) { + profileKey = storage.get('profileKey'); + } + const avatarPointer = ourConversation.get('avatarPointer'); + const { displayName } = ourConversation.getLokiProfile(); + return { displayName, avatarPointer, profileKey }; + } catch (e) { + window.log.error(`Failed to get our profile: ${e}`); + return null; + } + }, getNumber() { if (!this.isPrivate()) { diff --git a/ts/session/messages/outgoing/content/data/ChatMessage.ts b/ts/session/messages/outgoing/content/data/ChatMessage.ts index a82cdb37a..2ac442a3d 100644 --- a/ts/session/messages/outgoing/content/data/ChatMessage.ts +++ b/ts/session/messages/outgoing/content/data/ChatMessage.ts @@ -107,6 +107,9 @@ export class ChatMessage extends DataMessage { } if (this.profileKey) { dataMessage.profileKey = this.profileKey; + dataMessage.flags = + // tslint:disable-next-line: no-bitwise + dataMessage.flags | SignalService.DataMessage.Flags.PROFILE_KEY_UPDATE; } if (this.quote) {