diff --git a/web/src/actions/account.ts b/web/src/actions/account.ts index b1e3533..56fc5d1 100644 --- a/web/src/actions/account.ts +++ b/web/src/actions/account.ts @@ -151,15 +151,10 @@ export const accountActions = { permissions: 'user', input: z.object({ id: z.coerce.number().int().positive(), - displayName: z.string().max(100, 'Display name must be 100 characters or less').optional().nullable(), - link: z - .string() - .url('Must be a valid URL') - .max(255, 'URL must be 255 characters or less') - .optional() - .nullable(), + displayName: z.string().max(100, 'Display name must be 100 characters or less').nullable(), + link: z.string().url('Must be a valid URL').max(255, 'URL must be 255 characters or less').nullable(), pictureFile: imageFileSchema, - removePicture: z.coerce.boolean().default(false), + removePicture: z.coerce.boolean(), }), handler: async (input, context) => { if (input.id !== context.locals.user.id) { @@ -170,7 +165,7 @@ export const accountActions = { } if ( - input.displayName !== undefined && + input.displayName !== null && input.displayName !== context.locals.user.displayName && !context.locals.user.karmaUnlocks.displayName ) { @@ -181,7 +176,7 @@ export const accountActions = { } if ( - input.link !== undefined && + input.link !== null && input.link !== context.locals.user.link && !context.locals.user.karmaUnlocks.websiteLink ) { @@ -198,6 +193,13 @@ export const accountActions = { }) } + if (input.removePicture && !context.locals.user.karmaUnlocks.profilePicture) { + throw new ActionError({ + code: 'FORBIDDEN', + message: makeKarmaUnlockMessage(karmaUnlocksById.profilePicture), + }) + } + const pictureUrl = input.pictureFile && input.pictureFile.size > 0 ? await saveFileLocally( @@ -210,9 +212,13 @@ export const accountActions = { const user = await prisma.user.update({ where: { id: context.locals.user.id }, data: { - displayName: input.displayName ?? null, - link: input.link ?? null, - picture: input.removePicture ? null : (pictureUrl ?? undefined), + displayName: context.locals.user.karmaUnlocks.displayName ? (input.displayName ?? null) : undefined, + link: context.locals.user.karmaUnlocks.websiteLink ? (input.link ?? null) : undefined, + picture: context.locals.user.karmaUnlocks.profilePicture + ? input.removePicture + ? null + : (pictureUrl ?? undefined) + : undefined, }, }) diff --git a/web/src/components/ChatMessages.astro b/web/src/components/ChatMessages.astro index a87d70d..2897a23 100644 --- a/web/src/components/ChatMessages.astro +++ b/web/src/components/ChatMessages.astro @@ -75,9 +75,9 @@ const { messages, userId, class: className, ...htmlProps } = Astro.props {!!message.user.picture && ( )} @@ -86,16 +86,15 @@ const { messages, userId, class: className, ...htmlProps } = Astro.props )}

- {message.content} -

+ set:text={message.content} + /> {(!isPrevFromSameUser || !isPrevSameDate) && (

{message.formattedCreatedAt}

)} diff --git a/web/src/components/CommentItem.astro b/web/src/components/CommentItem.astro index a6c3e14..67ac3d1 100644 --- a/web/src/components/CommentItem.astro +++ b/web/src/components/CommentItem.astro @@ -371,8 +371,9 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin: comment.communityNote && (
- Added context: - {comment.communityNote} + + +
) diff --git a/web/src/components/CommentModeration.astro b/web/src/components/CommentModeration.astro index 72ae8f6..91e8be9 100644 --- a/web/src/components/CommentModeration.astro +++ b/web/src/components/CommentModeration.astro @@ -110,16 +110,18 @@ if (!user || !user.admin || !user.verifier) return null