Page MenuHomePhabricator

D7699.diff
No OneTemporary

D7699.diff

diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js
--- a/keyserver/src/responders/user-responders.js
+++ b/keyserver/src/responders/user-responders.js
@@ -28,6 +28,7 @@
import type {
ClientAvatar,
UpdateUserAvatarRequest,
+ UpdateUserAvatarResponse,
} from 'lib/types/avatar-types.js';
import type {
IdentityKeysBlob,
@@ -631,7 +632,7 @@
async function updateUserAvatarResponder(
viewer: Viewer,
input: any,
-): Promise<?ClientAvatar> {
+): Promise<?ClientAvatar | UpdateUserAvatarResponse> {
const request: UpdateUserAvatarRequest = input;
await validateInput(viewer, updateUserAvatarRequestValidator, request);
return await updateUserAvatar(viewer, request);
diff --git a/keyserver/src/updaters/account-updaters.js b/keyserver/src/updaters/account-updaters.js
--- a/keyserver/src/updaters/account-updaters.js
+++ b/keyserver/src/updaters/account-updaters.js
@@ -3,6 +3,7 @@
import invariant from 'invariant';
import bcrypt from 'twin-bcrypt';
+import { hasMinCodeVersion } from 'lib/shared/version-utils.js';
import type {
ResetPasswordRequest,
UpdatePasswordRequest,
@@ -12,9 +13,13 @@
import type {
ClientAvatar,
UpdateUserAvatarRequest,
+ UpdateUserAvatarResponse,
} from 'lib/types/avatar-types.js';
import { updateTypes } from 'lib/types/update-types.js';
-import type { UpdateData } from 'lib/types/update-types.js';
+import type {
+ CreateUpdatesResult,
+ UpdateData,
+} from 'lib/types/update-types.js';
import type {
PasswordUpdate,
UserInfo,
@@ -27,7 +32,6 @@
import { dbQuery, SQL } from '../database/database.js';
import { getUploadURL } from '../fetchers/upload-fetchers.js';
import { fetchKnownUserInfos } from '../fetchers/user-fetchers.js';
-import { handleAsyncPromise } from '../responders/handlers.js';
import type { Viewer } from '../session/viewer.js';
async function accountUpdater(
@@ -119,7 +123,7 @@
async function updateUserAvatar(
viewer: Viewer,
request: UpdateUserAvatarRequest,
-): Promise<?ClientAvatar> {
+): Promise<?ClientAvatar | UpdateUserAvatarResponse> {
if (!viewer.loggedIn) {
throw new ServerError('not_logged_in');
}
@@ -183,8 +187,17 @@
const selectResult = resultSet.pop();
const knownUserInfos: UserInfos = await fetchKnownUserInfos(viewer);
- const userUpdatesPromise = createUserAvatarUpdates(viewer, knownUserInfos);
- handleAsyncPromise(userUpdatesPromise);
+ const updates: CreateUpdatesResult = await createUserAvatarUpdates(
+ viewer,
+ knownUserInfos,
+ );
+
+ if (hasMinCodeVersion(viewer.platformDetails, 215)) {
+ const updateUserAvatarResponse: UpdateUserAvatarResponse = {
+ updates,
+ };
+ return updateUserAvatarResponse;
+ }
if (request.type === 'remove') {
return null;
@@ -208,7 +221,7 @@
async function createUserAvatarUpdates(
viewer: Viewer,
knownUserInfos: UserInfos,
-): Promise<void> {
+): Promise<CreateUpdatesResult> {
const time = Date.now();
const userUpdates: $ReadOnlyArray<UpdateData> = values(knownUserInfos).map(
(user: UserInfo): UpdateData => ({
@@ -225,7 +238,7 @@
time,
};
- await createUpdates([...userUpdates, currentUserUpdate], {
+ return await createUpdates([...userUpdates, currentUserUpdate], {
viewer,
updatesForCurrentSession: 'return',
});
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
@@ -1,5 +1,7 @@
// @flow
+import type { CreateUpdatesResult } from './update-types.js';
+
export type EmojiAvatarDBContent = {
+type: 'emoji',
+emoji: string,
@@ -39,3 +41,7 @@
| ClientENSAvatar;
export type ResolvedClientAvatar = ClientEmojiAvatar | ClientImageAvatar;
+
+export type UpdateUserAvatarResponse = {
+ +updates: CreateUpdatesResult,
+};

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 9:08 AM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611125
Default Alt Text
D7699.diff (3 KB)

Event Timeline