From 845aa1185c576c5a1772072bdf4cfadd335aead3 Mon Sep 17 00:00:00 2001 From: pluja Date: Wed, 21 May 2025 07:03:39 +0000 Subject: [PATCH] Release 2025-05-21-AQ5C --- web/src/actions/account.ts | 32 ++++--- web/src/components/ChatMessages.astro | 13 ++- web/src/components/CommentItem.astro | 5 +- web/src/components/CommentModeration.astro | 8 +- web/src/components/InputFile.astro | 15 ++- web/src/components/InputTextArea.astro | 5 +- web/src/components/MyPicture.astro | 6 ++ web/src/components/Tooltip.astro | 7 +- .../VerificationWarningBanner.astro | 2 +- web/src/constants/commentStatus.ts | 2 +- web/src/constants/commentStatusFilters.ts | 15 ++- web/src/constants/verificationStatus.ts | 2 +- web/src/pages/500.astro | 23 +++-- web/src/pages/access-denied.astro | 7 +- web/src/pages/account/edit.astro | 4 +- web/src/pages/account/index.astro | 78 ++++++++-------- web/src/pages/admin/attributes.astro | 8 +- .../admin/service-suggestions/[id].astro | 9 +- .../admin/service-suggestions/index.astro | 2 +- .../pages/admin/services/[slug]/edit.astro | 74 +++++++++------ web/src/pages/admin/services/new.astro | 23 +++-- web/src/pages/admin/users/[username].astro | 2 +- web/src/pages/notifications.astro | 2 +- web/src/pages/service-suggestion/[id].astro | 10 +- web/src/pages/u/[username].astro | 92 ++++++++++--------- 25 files changed, 261 insertions(+), 185 deletions(-) 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