Add avatar uploading to attachment utils

pull/1198/head
Mikunj 5 years ago
parent be4e540c62
commit 347a1e5582

@ -914,11 +914,13 @@
profileKey profileKey
); );
const avatarPointer = await textsecure.messaging.uploadAvatar({ const avatarPointer = await libsession.Utils.AttachmentUtils.uploadAvatar(
...data, {
data: encryptedData, ...data,
size: encryptedData.byteLength, data: encryptedData,
}); size: encryptedData.byteLength,
}
);
({ url } = avatarPointer); ({ url } = avatarPointer);

@ -104,6 +104,22 @@ export class AttachmentUtils {
return pointer; return pointer;
} }
public static async uploadAvatar(
attachment?: Attachment
): Promise<AttachmentPointer | undefined> {
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( public static async uploadAttachments(
attachments: Array<Attachment>, attachments: Array<Attachment>,
openGroup?: OpenGroup openGroup?: OpenGroup

Loading…
Cancel
Save