added profile description editing, fixed light theme and viewer caching

This commit is contained in:
lnn0q 2025-06-17 21:46:40 +03:00
parent 58a211663a
commit c8f68b7486
10 changed files with 187 additions and 18 deletions

View file

@ -0,0 +1,36 @@
import { ensureIdentity } from '@app/server/helpers';
import { IdentityContext } from '@app/server/identity';
import { prisma, uuid } from '@app/server/prisma/client';
import { MutationUserUpdateArgs, User } from '@generated/types';
import { toUserSchema } from './mappers/userMapper';
import { call } from '@app/common';
export async function UserUpdateResolver(
_: any,
{ input }: MutationUserUpdateArgs,
{ identity }: IdentityContext
): Promise<User> {
ensureIdentity(identity);
if (input.id != identity.id) throw new Error('Operation is not permitted.'); //todo: add admin access
if (input.description != null && input.description.length > 700)
throw new Error('Description is too long.');
const description = call((): string | null | undefined => {
if (input.description != null && input.description.length !== 0) return input.description;
if (input.description != null && input.description.length === 0) return null;
return undefined;
});
const updated = await prisma.user.update({
where: {
id: input.id
},
data: {
description
}
});
return toUserSchema(updated);
}