|
|
@ -16,7 +16,7 @@ import { containerFor, createQuerySpec, queryItems, getItem, normalize } from '. |
|
|
|
import { deleteMedia, attachMedia } from '../../lib/media' |
|
|
|
|
|
|
|
import { MAX_NAME_LENGTH } from '../../constants' |
|
|
|
import { userSchema, selfSchema, errorSchema } from '../../schemas' |
|
|
|
import { userSchema, selfSchema, errorSchema, userSettingsSchema } from '../../schemas' |
|
|
|
|
|
|
|
import { |
|
|
|
User, |
|
|
@ -28,6 +28,7 @@ import { |
|
|
|
GroupItemType, |
|
|
|
BlockType, |
|
|
|
UserInverseSubscription, |
|
|
|
UserSettings, |
|
|
|
} from '../../types/collections' |
|
|
|
|
|
|
|
import { PluginOptions } from '../../types' |
|
|
@ -88,6 +89,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp |
|
|
|
imageUrl?: string |
|
|
|
coverImageUrl?: string |
|
|
|
theme?: string |
|
|
|
settings?: UserSettings |
|
|
|
} |
|
|
|
|
|
|
|
const options: RouteShorthandOptions = { |
|
|
@ -108,6 +110,7 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp |
|
|
|
imageUrl: { type: 'string' }, |
|
|
|
coverImageUrl: { type: 'string' }, |
|
|
|
theme: { type: 'string' }, |
|
|
|
settings: userSettingsSchema, |
|
|
|
}, |
|
|
|
}, |
|
|
|
response: { |
|
|
@ -136,13 +139,8 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp |
|
|
|
if (about !== '') viewer.about = about |
|
|
|
} |
|
|
|
|
|
|
|
if (request.body.requiresApproval !== undefined) { |
|
|
|
viewer.requiresApproval = request.body.requiresApproval |
|
|
|
} |
|
|
|
|
|
|
|
if (request.body.privacy) { |
|
|
|
viewer.privacy = request.body.privacy |
|
|
|
} |
|
|
|
if (request.body.requiresApproval !== undefined) viewer.requiresApproval = request.body.requiresApproval |
|
|
|
if (request.body.privacy) viewer.privacy = request.body.privacy |
|
|
|
|
|
|
|
const mediaContainer = containerFor(server.database.client, 'Media') |
|
|
|
|
|
|
@ -152,17 +150,10 @@ function updateRoute(server: FastifyInstance<Server, IncomingMessage, ServerResp |
|
|
|
if (!viewer.imageUrl && request.body.imageUrl) await attachMedia(mediaContainer, request.body.imageUrl) |
|
|
|
if (!viewer.coverImageUrl && request.body.coverImageUrl) await attachMedia(mediaContainer, request.body.coverImageUrl) |
|
|
|
|
|
|
|
if (request.body.imageUrl) { |
|
|
|
viewer.imageUrl = request.body.imageUrl |
|
|
|
} |
|
|
|
|
|
|
|
if (request.body.coverImageUrl) { |
|
|
|
viewer.coverImageUrl = request.body.coverImageUrl |
|
|
|
} |
|
|
|
|
|
|
|
if (request.body.theme) { |
|
|
|
viewer.theme = request.body.theme |
|
|
|
} |
|
|
|
if (request.body.imageUrl) viewer.imageUrl = request.body.imageUrl |
|
|
|
if (request.body.coverImageUrl) viewer.coverImageUrl = request.body.coverImageUrl |
|
|
|
if (request.body.theme) viewer.theme = request.body.theme |
|
|
|
if (request.body.settings) viewer.settings = request.body.settings |
|
|
|
|
|
|
|
await viewerItem.replace<User>(viewer) |
|
|
|
return viewer |
|
|
|