diff --git a/keyserver/src/fetchers/user-fetchers.js b/keyserver/src/fetchers/user-fetchers.js --- a/keyserver/src/fetchers/user-fetchers.js +++ b/keyserver/src/fetchers/user-fetchers.js @@ -200,7 +200,7 @@ viewer: Viewer, ): Promise { const userQuery = SQL` - SELECT id, username + SELECT id, username, avatar FROM users WHERE id = ${viewer.userID} `; @@ -228,7 +228,7 @@ } const id = userRow.id.toString(); - const { username } = userRow; + const { username, avatar } = userRow; if (stillExpectsEmailFields) { return { @@ -239,18 +239,30 @@ }; } + let loggedInUserInfo: LoggedInUserInfo = { + id, + username, + }; + + const shouldIncludeAvatar = hasMinCodeVersion(viewer.platformDetails, 1000); + + if (shouldIncludeAvatar && avatar) { + loggedInUserInfo = { ...loggedInUserInfo, avatar }; + } + const featureGateSettings = !hasMinCodeVersion(viewer.platformDetails, 1000); if (featureGateSettings) { - return { id, username }; + return loggedInUserInfo; } const settings = settingsResult.reduce((prev, curr) => { prev[curr.name] = curr.data; return prev; }, {}); + loggedInUserInfo = { ...loggedInUserInfo, settings }; - return { id, username, settings }; + return loggedInUserInfo; } async function fetchAllUserIDs(): Promise { diff --git a/lib/types/user-types.js b/lib/types/user-types.js --- a/lib/types/user-types.js +++ b/lib/types/user-types.js @@ -1,6 +1,7 @@ // @flow import type { DefaultNotificationPayload } from './account-types.js'; +import type { AvatarDBContent } from './avatar-types'; import type { UserRelationshipStatus } from './relationship-types.js'; import type { UserInconsistencyReportCreationRequest } from './report-types.js'; @@ -48,6 +49,7 @@ export type LoggedInUserInfo = { +id: string, +username: string, + +avatar?: AvatarDBContent, +settings?: DefaultNotificationPayload, };