From 0b603ae5896ea6b0b8250d05082bb473fb8bbabd Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Thu, 30 Nov 2023 11:07:06 -0500 Subject: [PATCH 1/3] add rejection notification copy updates --- .../RejectedCommentNotificationBody.tsx | 26 ++++++++++++------- locales/en-US/stream.ftl | 18 ++++++------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx b/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx index 2071b2678a..5d0a3999a3 100644 --- a/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx +++ b/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx @@ -60,18 +60,22 @@ const getGeneralReason = ( return getMessage( bundles, "notifications-rejectionReason-offensive", - "Offensive" + "This comment contains offensive language" ); } if (reason === GQLREJECTION_REASON_CODE.ABUSIVE) { return getMessage( bundles, "notifications-rejectionReason-abusive", - "Abusive" + "This comment contains abusive language" ); } if (reason === GQLREJECTION_REASON_CODE.SPAM) { - return getMessage(bundles, "notifications-rejectionReason-spam", "Spam"); + return getMessage( + bundles, + "notifications-rejectionReason-spam", + "This comment is spam" + ); } if (reason === GQLREJECTION_REASON_CODE.BANNED_WORD) { return getMessage( @@ -81,13 +85,17 @@ const getGeneralReason = ( ); } if (reason === GQLREJECTION_REASON_CODE.AD) { - return getMessage(bundles, "notifications-rejectionReason-ad", "Ad"); + return getMessage( + bundles, + "notifications-rejectionReason-ad", + "This comment is an advertisement" + ); } if (reason === GQLREJECTION_REASON_CODE.ILLEGAL_CONTENT) { return getMessage( bundles, "notifications-rejectionReason-illegalContent", - "Illegal content" + "This comment contains illegal content" ); } @@ -95,28 +103,28 @@ const getGeneralReason = ( return getMessage( bundles, "notifications-rejectionReason-harassmentBullying", - "Harassment or bullying" + "This comment contains harassing or bullying language" ); } if (reason === GQLREJECTION_REASON_CODE.MISINFORMATION) { return getMessage( bundles, "notifications-rejectionReason-misinformation", - "Misinformation" + "This comment contains misinformation" ); } if (reason === GQLREJECTION_REASON_CODE.HATE_SPEECH) { return getMessage( bundles, "notifications-rejectionReason-hateSpeech", - "Hate speech" + "This comment contains hate speech" ); } if (reason === GQLREJECTION_REASON_CODE.IRRELEVANT_CONTENT) { return getMessage( bundles, "notifications-rejectionReason-irrelevant", - "Irrelevant content" + "This comment is irrelevant to the discussion" ); } diff --git a/locales/en-US/stream.ftl b/locales/en-US/stream.ftl index b17e410e5e..4d11a3488e 100644 --- a/locales/en-US/stream.ftl +++ b/locales/en-US/stream.ftl @@ -1063,16 +1063,16 @@ notifications-dsaReportLegality-legal = Legal content notifications-dsaReportLegality-illegal = Illegal content notifications-dsaReportLegality-unknown = Unknown -notifications-rejectionReason-offensive = Offensive -notifications-rejectionReason-abusive = Abusive -notifications-rejectionReason-spam = Spam +notifications-rejectionReason-offensive = This comment contains offensive language +notifications-rejectionReason-abusive = This comment contains abusive language +notifications-rejectionReason-spam = This comment is spam notifications-rejectionReason-bannedWord = Banned word -notifications-rejectionReason-ad = Ad -notifications-rejectionReason-illegalContent = Illegal content -notifications-rejectionReason-harassmentBullying = Harassment or bullying -notifications-rejectionReason-misinformation = Misinformation -notifications-rejectionReason-hateSpeech = Hate speech -notifications-rejectionReason-irrelevant = Irrelevant content +notifications-rejectionReason-ad = This comment is an advertisement +notifications-rejectionReason-illegalContent = This comment contains illegal content +notifications-rejectionReason-harassmentBullying = This comment contains harassing or bullying language +notifications-rejectionReason-misinformation = This comment contains misinformation +notifications-rejectionReason-hateSpeech = This comment contains hate speech +notifications-rejectionReason-irrelevant = This comment is irrelevant to the discussion notifications-rejectionReason-other = Other notifications-rejectionReason-unknown = Unknown From 48afadcea726df85ecf09fbfb4a5112841bf301f Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Thu, 30 Nov 2023 15:14:00 -0500 Subject: [PATCH 2/3] show customreason for other type notification; dont notify banned word reject --- .../RejectedCommentNotificationBody.tsx | 24 +++++++++++++++---- locales/en-US/stream.ftl | 1 + .../core/server/graph/schema/schema.graphql | 15 ++++++++++++ .../models/notifications/notification.ts | 1 + .../notifications/internal/context.ts | 2 ++ .../src/core/server/stacks/rejectComment.ts | 5 +++- 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx b/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx index 5d0a3999a3..280f335aab 100644 --- a/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx +++ b/client/src/core/client/stream/tabs/Notifications/RejectedCommentNotificationBody.tsx @@ -54,7 +54,8 @@ const getLegalReason = ( const getGeneralReason = ( bundles: FluentBundle[], - reason: REJECTION_REASON_CODE | null + reason: REJECTION_REASON_CODE | null, + customReason: string | null ) => { if (reason === GQLREJECTION_REASON_CODE.OFFENSIVE) { return getMessage( @@ -129,7 +130,20 @@ const getGeneralReason = ( } if (reason === GQLREJECTION_REASON_CODE.OTHER) { - return getMessage(bundles, "notifications-rejectionReason-other", "Other"); + if (customReason) { + return getMessage( + bundles, + "notifications-rejectionReason-other-customReason", + `Other - ${customReason}`, + { vars: { customReason } } + ); + } else { + return getMessage( + bundles, + "notifications-rejectionReason-other", + "Other" + ); + } } return getMessage( @@ -146,7 +160,8 @@ const stringIsNullOrEmpty = (value: string) => { const RejectedCommentNotificationBody: FunctionComponent = ({ notification, }) => { - const { type, decisionDetails, rejectionReason, comment } = notification; + const { type, decisionDetails, rejectionReason, customReason, comment } = + notification; const { localeBundles } = useCoralContext(); @@ -173,7 +188,7 @@ const RejectedCommentNotificationBody: FunctionComponent = ({
Reason for removal
- {getGeneralReason(localeBundles, rejectionReason)} + {getGeneralReason(localeBundles, rejectionReason, customReason)}
{hasExplanation && ( <> @@ -245,6 +260,7 @@ const enhanced = withFragmentContainer({ fragment RejectedCommentNotificationBody_notification on Notification { type rejectionReason + customReason decisionDetails { legality grounds diff --git a/locales/en-US/stream.ftl b/locales/en-US/stream.ftl index 4d11a3488e..6e07f3b974 100644 --- a/locales/en-US/stream.ftl +++ b/locales/en-US/stream.ftl @@ -1074,6 +1074,7 @@ notifications-rejectionReason-misinformation = This comment contains misinformat notifications-rejectionReason-hateSpeech = This comment contains hate speech notifications-rejectionReason-irrelevant = This comment is irrelevant to the discussion notifications-rejectionReason-other = Other +notifications-rejectionReason-other-customReason = Other - { $customReason } notifications-rejectionReason-unknown = Unknown notifications-reportDecisionMade-legal = diff --git a/server/src/core/server/graph/schema/schema.graphql b/server/src/core/server/graph/schema/schema.graphql index c2ab69385a..61c1452ead 100644 --- a/server/src/core/server/graph/schema/schema.graphql +++ b/server/src/core/server/graph/schema/schema.graphql @@ -3459,6 +3459,11 @@ type RejectionReason { detailedExplanation is any additional information the user wishes to provide. """ detailedExplanation: String + + """ + customReason is a reason provided for rejection when the Other rejection code is selected. + """ + customReason: String } type CommentModerationAction { @@ -3494,6 +3499,11 @@ type CommentModerationAction { createdAt is the time that the CommentModerationAction was created. """ createdAt: Time! + + """ + customReason is a reason provided for rejection when the Other rejection code is selected. + """ + customReason: String } type CommentModerationActionEdge { @@ -4786,6 +4796,11 @@ type Notification { """ decisionDetails: NotificationDecisionDetails + """ + customReason is a reason provided for rejection when the Other rejection code is selected. + """ + customReason: String + """ dsaReport is the details of the DSA Report related to the notification. This is usually in reference to the comment that is also related to diff --git a/server/src/core/server/models/notifications/notification.ts b/server/src/core/server/models/notifications/notification.ts index c514d36b2d..cefe6d1bde 100644 --- a/server/src/core/server/models/notifications/notification.ts +++ b/server/src/core/server/models/notifications/notification.ts @@ -27,6 +27,7 @@ export interface Notification extends TenantResource { rejectionReason?: GQLREJECTION_REASON_CODE; decisionDetails?: GQLNotificationDecisionDetails; + customReason?: string; } type BaseConnectionInput = ConnectionInput; diff --git a/server/src/core/server/services/notifications/internal/context.ts b/server/src/core/server/services/notifications/internal/context.ts index a5ed0f8bd7..d25c0f5652 100644 --- a/server/src/core/server/services/notifications/internal/context.ts +++ b/server/src/core/server/services/notifications/internal/context.ts @@ -28,6 +28,7 @@ export interface RejectionReasonInput { code: GQLREJECTION_REASON_CODE; legalGrounds?: string | undefined; detailedExplanation?: string | undefined; + customReason?: string | undefined; } export interface CreateNotificationInput { @@ -164,6 +165,7 @@ export class InternalNotificationContext { commentID: comment.id, commentStatus: comment.status, rejectionReason: rejectionReason?.code ?? undefined, + customReason: rejectionReason?.customReason ?? undefined, decisionDetails: { explanation: rejectionReason?.detailedExplanation ?? undefined, }, diff --git a/server/src/core/server/stacks/rejectComment.ts b/server/src/core/server/stacks/rejectComment.ts index 2cadeadd3b..f41c66e4dd 100644 --- a/server/src/core/server/stacks/rejectComment.ts +++ b/server/src/core/server/stacks/rejectComment.ts @@ -164,7 +164,10 @@ const rejectComment = async ( }); } - if (sendNotification) { + if ( + sendNotification && + !(reason?.code === GQLREJECTION_REASON_CODE.BANNED_WORD) + ) { await notifications.create(tenant.id, tenant.locale, { targetUserID: result.after.authorID!, comment: result.after, From e7438f9d7b4c22fde88eaa13ac62f525169946f5 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Fri, 1 Dec 2023 09:18:38 -0500 Subject: [PATCH 3/3] add customReason to notification resolver --- server/src/core/server/graph/resolvers/Notification.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/core/server/graph/resolvers/Notification.ts b/server/src/core/server/graph/resolvers/Notification.ts index be650fcdbb..cd765f1766 100644 --- a/server/src/core/server/graph/resolvers/Notification.ts +++ b/server/src/core/server/graph/resolvers/Notification.ts @@ -29,4 +29,5 @@ export const NotificationResolver: Required< }, decisionDetails: ({ decisionDetails }) => decisionDetails, rejectionReason: ({ rejectionReason }) => rejectionReason, + customReason: ({ customReason }) => customReason, };