Page MenuHomePhabricator

D9169.diff
No OneTemporary

D9169.diff

diff --git a/lib/types/avatar-types.js b/lib/types/avatar-types.js
--- a/lib/types/avatar-types.js
+++ b/lib/types/avatar-types.js
@@ -65,6 +65,12 @@
+encryptionKey: string,
+thumbHash: ?string,
};
+const clientEncryptedImageAvatarValidator = tShape<ClientEncryptedImageAvatar>({
+ type: tString('encrypted_image'),
+ blobURI: t.String,
+ encryptionKey: t.String,
+ thumbHash: t.maybe(t.String),
+});
export type ClientENSAvatar = ENSAvatarDBContent;
const clientENSAvatarValidator = ensAvatarDBContentValidator;
@@ -78,6 +84,7 @@
clientEmojiAvatarValidator,
clientImageAvatarValidator,
clientENSAvatarValidator,
+ clientEncryptedImageAvatarValidator,
]);
export type ResolvedClientAvatar =
diff --git a/lib/utils/avatar-utils.js b/lib/utils/avatar-utils.js
--- a/lib/utils/avatar-utils.js
+++ b/lib/utils/avatar-utils.js
@@ -17,6 +17,12 @@
uploadID: tID,
});
+const encryptedImageAvatarDBContentValidator: TInterface<ImageAvatarDBContent> =
+ tShape({
+ type: tString('encrypted_image'),
+ uploadID: tID,
+ });
+
const updateUserAvatarRemoveRequestValidator: TInterface<UpdateUserAvatarRemoveRequest> =
tShape({
type: tString('remove'),
@@ -26,6 +32,7 @@
t.union([
emojiAvatarDBContentValidator,
imageAvatarDBContentValidator,
+ encryptedImageAvatarDBContentValidator,
ensAvatarDBContentValidator,
updateUserAvatarRemoveRequestValidator,
]);
@@ -33,6 +40,7 @@
export {
emojiAvatarDBContentValidator,
imageAvatarDBContentValidator,
+ encryptedImageAvatarDBContentValidator,
ensAvatarDBContentValidator,
updateUserAvatarRemoveRequestValidator,
updateUserAvatarRequestValidator,
diff --git a/lib/utils/avatar-utils.test.js b/lib/utils/avatar-utils.test.js
--- a/lib/utils/avatar-utils.test.js
+++ b/lib/utils/avatar-utils.test.js
@@ -4,6 +4,7 @@
emojiAvatarDBContentValidator,
ensAvatarDBContentValidator,
imageAvatarDBContentValidator,
+ encryptedImageAvatarDBContentValidator,
updateUserAvatarRequestValidator,
} from './avatar-utils.js';
@@ -85,6 +86,35 @@
});
});
+describe('encryptedImageAvatarDBContentValidator', () => {
+ it('should succeed for valid input', () => {
+ expect(
+ encryptedImageAvatarDBContentValidator.is({
+ type: 'encrypted_image',
+ uploadID: '123456',
+ }),
+ ).toBe(true);
+ });
+
+ it('should fail if type is incorrect', () => {
+ expect(
+ encryptedImageAvatarDBContentValidator.is({
+ type: 'emoji',
+ uploadID: '123456',
+ }),
+ ).toBe(false);
+ });
+
+ it('should fail if uploadID is incorrect type', () => {
+ expect(
+ encryptedImageAvatarDBContentValidator.is({
+ type: 'encrypted_image',
+ uploadID: 123456,
+ }),
+ ).toBe(false);
+ });
+});
+
describe('ensAvatarDBContentValidator', () => {
it('should succeed for valid input', () => {
expect(

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 3:17 AM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2859164
Default Alt Text
D9169.diff (2 KB)

Event Timeline