diff --git a/js/background.js b/js/background.js index c3b33e0ae..32f2e7cd4 100644 --- a/js/background.js +++ b/js/background.js @@ -914,11 +914,13 @@ profileKey ); - const avatarPointer = await textsecure.messaging.uploadAvatar({ - ...data, - data: encryptedData, - size: encryptedData.byteLength, - }); + const avatarPointer = await libsession.Utils.AttachmentUtils.uploadAvatar( + { + ...data, + data: encryptedData, + size: encryptedData.byteLength, + } + ); ({ url } = avatarPointer); diff --git a/ts/session/utils/Attachments.ts b/ts/session/utils/Attachments.ts index 7199d535e..a1de04c9a 100644 --- a/ts/session/utils/Attachments.ts +++ b/ts/session/utils/Attachments.ts @@ -104,6 +104,22 @@ export class AttachmentUtils { return pointer; } + public static async uploadAvatar( + attachment?: Attachment + ): Promise { + if (!attachment) { + return undefined; + } + + // isRaw is true since the data is already encrypted + // and doesn't need to be encrypted again + return this.upload({ + attachment, + isAvatar: true, + isRaw: true, + }); + } + public static async uploadAttachments( attachments: Array, openGroup?: OpenGroup