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 @@ -14,12 +14,23 @@ UpdateUserAvatarRequest, } from 'lib/types/avatar-types.js'; import { updateTypes } from 'lib/types/update-types.js'; -import type { PasswordUpdate } from 'lib/types/user-types.js'; +import type { + CreateUpdatesResult, + UpdateData, +} from 'lib/types/update-types.js'; +import type { + PasswordUpdate, + UserInfo, + UserInfos, +} from 'lib/types/user-types.js'; import { ServerError } from 'lib/utils/errors.js'; +import { values } from 'lib/utils/objects.js'; import { createUpdates } from '../creators/update-creator.js'; 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( @@ -174,6 +185,26 @@ const [resultSet] = await dbQuery(query, { multipleStatements: true }); const selectResult = resultSet.pop(); + const knownUserInfos: UserInfos = await fetchKnownUserInfos(viewer); + const usersToUpdate: $ReadOnlyArray = values(knownUserInfos).filter( + (user: UserInfo): boolean => user.id !== viewer.userID, + ); + + const time = Date.now(); + const updateData: $ReadOnlyArray = usersToUpdate.map( + (user: UserInfo): UpdateData => ({ + type: updateTypes.UPDATE_USER, + userID: user.id, + time, + updatedUserID: viewer.userID, + }), + ); + + const userUpdatesPromise: Promise = + createUpdates(updateData); + + handleAsyncPromise(userUpdatesPromise); + if (request.type === 'remove') { return null; } else if (request.type !== 'image') {