From ca00c5bd0d334f65d38dc9da60b2e52d1dc4d629 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 09:28:39 -0500 Subject: [PATCH 1/8] add rejectionreason when reject all comments selected for user ban and dsa --- .../core/client/admin/components/BanModal.css | 9 ++ .../core/client/admin/components/BanModal.tsx | 93 +++++++++++++++++-- .../ModerationReason/DetailedExplanation.tsx | 5 +- .../ModerationReason/ModerationReason.css | 1 + .../ModerationReason/ModerationReason.tsx | 13 +-- .../src/core/server/graph/mutators/Users.ts | 4 + .../core/server/graph/schema/schema.graphql | 4 + .../src/core/server/services/users/users.ts | 25 +---- 8 files changed, 113 insertions(+), 41 deletions(-) diff --git a/client/src/core/client/admin/components/BanModal.css b/client/src/core/client/admin/components/BanModal.css index 6b9d7472b6..91428cd758 100644 --- a/client/src/core/client/admin/components/BanModal.css +++ b/client/src/core/client/admin/components/BanModal.css @@ -39,3 +39,12 @@ $ban-modal-text: var(--palette-text-500); .customizeMessageArrowsIcon { padding-left: var(--spacing-1); } + +.rejectionReasonLink { + width: fit-content; + color: var(--palette-primary-600) !important; +} + +.rejectExistingReason { + background-color: var(--palette-grey-100); +} diff --git a/client/src/core/client/admin/components/BanModal.tsx b/client/src/core/client/admin/components/BanModal.tsx index f7887d2016..1450d391c7 100644 --- a/client/src/core/client/admin/components/BanModal.tsx +++ b/client/src/core/client/admin/components/BanModal.tsx @@ -8,13 +8,18 @@ import React, { useState, } from "react"; import { Form } from "react-final-form"; +import { graphql } from "react-relay"; import NotAvailable from "coral-admin/components/NotAvailable"; import { PROTECTED_EMAIL_DOMAINS } from "coral-common/common/lib/constants"; import { extractDomain } from "coral-common/common/lib/email"; +import { + isOrgModerator, + isSiteModerator, +} from "coral-common/common/lib/permissions/types"; import { useGetMessage } from "coral-framework/lib/i18n"; -import { useMutation } from "coral-framework/lib/relay"; -import { GQLUSER_ROLE } from "coral-framework/schema"; +import { useLocal, useMutation } from "coral-framework/lib/relay"; +import { GQLREJECTION_REASON_CODE, GQLUSER_ROLE } from "coral-framework/schema"; import { ArrowsDownIcon, ArrowsUpIcon, @@ -32,6 +37,7 @@ import { } from "coral-ui/components/v2"; import { CallOut } from "coral-ui/components/v3"; +import { BanModalLocal } from "coral-admin/__generated__/BanModalLocal.graphql"; import { UserStatusChangeContainer_settings } from "coral-admin/__generated__/UserStatusChangeContainer_settings.graphql"; import { UserStatusChangeContainer_user } from "coral-admin/__generated__/UserStatusChangeContainer_user.graphql"; import { UserStatusChangeContainer_viewer } from "coral-admin/__generated__/UserStatusChangeContainer_viewer.graphql"; @@ -40,16 +46,14 @@ import BanDomainMutation from "./BanDomainMutation"; import BanUserMutation from "./BanUserMutation"; import ModalHeader from "./ModalHeader"; import ModalHeaderUsername from "./ModalHeaderUsername"; +import DetailedExplanation from "./ModerationReason/DetailedExplanation"; +import Reasons from "./ModerationReason/Reasons"; import RemoveUserBanMutation from "./RemoveUserBanMutation"; import UpdateUserBanMutation from "./UpdateUserBanMutation"; import ChangeStatusModal from "./UserStatus/ChangeStatusModal"; import { getTextForUpdateType } from "./UserStatus/helpers"; import UserStatusSitesList from "./UserStatus/UserStatusSitesList"; -import { - isOrgModerator, - isSiteModerator, -} from "coral-common/common/lib/permissions/types"; import styles from "./BanModal.css"; export enum UpdateType { @@ -140,6 +144,12 @@ const BanModal: FunctionComponent = ({ const updateUserBan = useMutation(UpdateUserBanMutation); const removeUserBan = useMutation(RemoveUserBanMutation); + const [{ dsaFeaturesEnabled }] = useLocal(graphql` + fragment BanModalLocal on Local { + dsaFeaturesEnabled + } + `); + const getMessage = useGetMessage(); const getDefaultMessage = useMemo((): string => { return getMessage( @@ -203,6 +213,17 @@ const BanModal: FunctionComponent = ({ ({ domain }) => domain === emailDomain ); + const [view, setView] = useState<"REASON" | "EXPLANATION">("REASON"); + const [reasonCode, setReasonCode] = useState( + null + ); + const [detailedExplanation, setDetailedExplanation] = useState( + null + ); + const [otherCustomReason, setOtherCustomReason] = useState( + null + ); + const canBanDomain = (viewer.role === GQLUSER_ROLE.ADMIN || (viewer.role === GQLUSER_ROLE.MODERATOR && !isSiteModerator(viewer))) && @@ -227,6 +248,13 @@ const BanModal: FunctionComponent = ({ userID, // Should be defined because the modal shouldn't open if author is null message: customizeMessage ? emailMessage : getDefaultMessage, rejectExistingComments, + rejectionReason: rejectExistingComments + ? { + code: reasonCode!, + detailedExplanation, + customReason: otherCustomReason, + } + : undefined, siteIDs: viewerIsScoped ? viewer?.moderationScopes?.sites?.map(({ id }) => id) : [], @@ -243,6 +271,13 @@ const BanModal: FunctionComponent = ({ banSiteIDs, unbanSiteIDs, rejectExistingComments, + rejectionReason: rejectExistingComments + ? { + code: reasonCode!, + detailedExplanation, + customReason: otherCustomReason, + } + : undefined, }); } catch (err) { return { [FORM_ERROR]: err.message }; @@ -281,6 +316,9 @@ const BanModal: FunctionComponent = ({ removeUserBan, createDomainBan, emailDomain, + reasonCode, + detailedExplanation, + otherCustomReason, ]); const { @@ -296,7 +334,16 @@ const BanModal: FunctionComponent = ({ const requiresSiteBanUpdates = updateType === UpdateType.SPECIFIC_SITES || (updateType === UpdateType.ALL_SITES && viewerIsSingleSiteMod); - const disableForm = requiresSiteBanUpdates && !pendingSiteBanUpdates; + // disable if reject all comments doesn't have a reason if dsa is enabled + // also disable if Other reason and not a custom reason included + const requiresRejectionReason = + rejectExistingComments && + !!dsaFeaturesEnabled && + (!reasonCode || + (reasonCode === GQLREJECTION_REASON_CODE.OTHER && !otherCustomReason)); + const disableForm = + (requiresSiteBanUpdates && !pendingSiteBanUpdates) || + requiresRejectionReason; return ( = ({ )} + {rejectExistingComments && dsaFeaturesEnabled && ( + + {view === "REASON" ? ( + { + setReasonCode(code); + setView("EXPLANATION"); + }} + /> + ) : ( + { + setView("REASON"); + setReasonCode(null); + }} + code={reasonCode!} + explanationValue={detailedExplanation} + onChangeExplanation={setDetailedExplanation} + customReasonValue={otherCustomReason} + onChangeCustomReason={setOtherCustomReason} + linkClassName={styles.rejectionReasonLink} + /> + )} + + )} {/* EMAIL BAN */} {canBanDomain && ( diff --git a/client/src/core/client/admin/components/ModerationReason/DetailedExplanation.tsx b/client/src/core/client/admin/components/ModerationReason/DetailedExplanation.tsx index cea272e759..fab9cc6906 100644 --- a/client/src/core/client/admin/components/ModerationReason/DetailedExplanation.tsx +++ b/client/src/core/client/admin/components/ModerationReason/DetailedExplanation.tsx @@ -119,7 +119,10 @@ const DetailedExplanation: FunctionComponent = ({ ) : ( - setShowAddExplanation(true)} /> + setShowAddExplanation(true)} + linkClassName={linkClassName} + /> )} ); diff --git a/client/src/core/client/admin/components/ModerationReason/ModerationReason.css b/client/src/core/client/admin/components/ModerationReason/ModerationReason.css index 75e9773d61..cfe903c2e1 100644 --- a/client/src/core/client/admin/components/ModerationReason/ModerationReason.css +++ b/client/src/core/client/admin/components/ModerationReason/ModerationReason.css @@ -13,6 +13,7 @@ .optionAction { padding: 0; margin: var(--spacing-1) 0; + width: fit-content; } .rejectButton { diff --git a/client/src/core/client/admin/components/ModerationReason/ModerationReason.tsx b/client/src/core/client/admin/components/ModerationReason/ModerationReason.tsx index f7dc4fe607..ac151c5e55 100644 --- a/client/src/core/client/admin/components/ModerationReason/ModerationReason.tsx +++ b/client/src/core/client/admin/components/ModerationReason/ModerationReason.tsx @@ -30,7 +30,6 @@ const ModerationReason: FunctionComponent = ({ const [view, setView] = useState<"REASON" | "EXPLANATION">("REASON"); const [reasonCode, setReasonCode] = useState(null); - const [legalGrounds] = useState(null); const [detailedExplanation, setDetailedExplanation] = useState( null ); @@ -41,20 +40,10 @@ const ModerationReason: FunctionComponent = ({ const submitReason = useCallback(() => { onReason({ code: reasonCode!, - legalGrounds: - reasonCode === GQLREJECTION_REASON_CODE.ILLEGAL_CONTENT - ? legalGrounds - : undefined, detailedExplanation: detailedExplanation || undefined, customReason: otherCustomReason || undefined, }); - }, [ - reasonCode, - legalGrounds, - detailedExplanation, - onReason, - otherCustomReason, - ]); + }, [reasonCode, detailedExplanation, onReason, otherCustomReason]); return ( diff --git a/server/src/core/server/graph/mutators/Users.ts b/server/src/core/server/graph/mutators/Users.ts index 73b3d65428..de47b64363 100644 --- a/server/src/core/server/graph/mutators/Users.ts +++ b/server/src/core/server/graph/mutators/Users.ts @@ -336,6 +336,7 @@ export const Users = (ctx: GraphContext) => ({ message, rejectExistingComments = false, siteIDs, + rejectionReason, }: GQLBanUserInput) => ban( ctx.mongo, @@ -349,6 +350,7 @@ export const Users = (ctx: GraphContext) => ({ ctx.i18n, rejectExistingComments, siteIDs, + rejectionReason, ctx.now ), updateUserBan: @@ -358,6 +360,7 @@ export const Users = (ctx: GraphContext) => ({ rejectExistingComments = false, banSiteIDs, unbanSiteIDs, + rejectionReason, }: GQLUpdateUserBanInput) => async () => updateUserBan( @@ -373,6 +376,7 @@ export const Users = (ctx: GraphContext) => ({ rejectExistingComments, banSiteIDs, unbanSiteIDs, + rejectionReason, ctx.now ), warn: async (input: GQLWarnUserInput) => diff --git a/server/src/core/server/graph/schema/schema.graphql b/server/src/core/server/graph/schema/schema.graphql index 58eb8f4139..0e1fd70b98 100644 --- a/server/src/core/server/graph/schema/schema.graphql +++ b/server/src/core/server/graph/schema/schema.graphql @@ -8875,6 +8875,8 @@ input BanUserInput { whether or not to reject all the user's previous comments when banning them. """ rejectExistingComments: Boolean + + rejectionReason: RejectCommentReasonInput } type BanUserPayload { @@ -8917,6 +8919,8 @@ input UpdateUserBanInput { """ rejectExistingComments: Boolean + rejectionReason: RejectCommentReasonInput + """ clientMutationID is required for relay support """ diff --git a/server/src/core/server/services/users/users.ts b/server/src/core/server/services/users/users.ts index 6858dec264..bfe3e2c08b 100644 --- a/server/src/core/server/services/users/users.ts +++ b/server/src/core/server/services/users/users.ts @@ -115,6 +115,7 @@ import { sendConfirmationEmail } from "coral-server/services/users/auth"; import { GQLAuthIntegrations, GQLREJECTION_REASON_CODE, + GQLRejectionReason, GQLUSER_ROLE, } from "coral-server/graph/schema/__generated__/types"; @@ -1389,6 +1390,7 @@ export async function ban( i18n: I18n, rejectExistingComments: boolean, siteIDs?: string[] | null, + rejectionReason?: GQLRejectionReason, now = new Date() ) { // Get the user being banned to check to see if the user already has an @@ -1468,17 +1470,6 @@ export async function ban( let user: Readonly; - const bundle = i18n.getBundle(tenant.locale); - const tranlsatedExplanation = translate( - bundle, - "common-userBanned", - "User banned." - ); - const rejectionReason = { - code: GQLREJECTION_REASON_CODE.OTHER, - detailedExplanation: tranlsatedExplanation, - }; - // Perform a site ban if (siteIDs && siteIDs.length > 0) { user = await siteBanUser( @@ -1614,6 +1605,7 @@ export async function updateUserBan( rejectExistingComments: boolean, banSiteIDs?: string[] | null, unbanSiteIDs?: string[] | null, + rejectionReason?: GQLRejectionReason, now = new Date() ) { // Ensure valid role @@ -1703,21 +1695,12 @@ export async function updateUserBan( // if any new bans and rejectExistingCommments, reject existing comments if (rejectExistingComments) { - const bundle = i18n.getBundle(tenant.locale); - const detailedExplanation = translate( - bundle, - "common-userBanned", - "User was banned." - ); await rejector.add({ tenantID: tenant.id, authorID: targetUser.id, moderatorID: banner.id, siteIDs: idsToBan, - reason: { - code: GQLREJECTION_REASON_CODE.OTHER, - detailedExplanation, - }, + reason: rejectionReason, }); } From c899d821ec2c8725c533cfe02d31f6a709d8b25c Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 09:30:11 -0500 Subject: [PATCH 2/8] remove unused imports --- server/src/core/server/services/users/users.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/core/server/services/users/users.ts b/server/src/core/server/services/users/users.ts index bfe3e2c08b..e94322f349 100644 --- a/server/src/core/server/services/users/users.ts +++ b/server/src/core/server/services/users/users.ts @@ -114,12 +114,11 @@ import { sendConfirmationEmail } from "coral-server/services/users/auth"; import { GQLAuthIntegrations, - GQLREJECTION_REASON_CODE, GQLRejectionReason, GQLUSER_ROLE, } from "coral-server/graph/schema/__generated__/types"; -import { I18n, translate } from "../i18n"; +import { I18n } from "../i18n"; import { AugmentedRedis } from "../redis"; import { generateAdminDownloadLink, From cb15ba5f880f3b362a702b5d65cb98d846646532 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 10:29:08 -0500 Subject: [PATCH 3/8] update spam rejection reason for spam ban --- .../Comments/Comment/UserBanPopover/BanUserMutation.ts | 1 + .../Comment/UserBanPopover/UserBanPopoverContainer.tsx | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/BanUserMutation.ts b/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/BanUserMutation.ts index ee9629bb9d..58061a013d 100644 --- a/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/BanUserMutation.ts +++ b/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/BanUserMutation.ts @@ -61,6 +61,7 @@ const BanUserMutation = createMutation( message: input.message, rejectExistingComments: input.rejectExistingComments, siteIDs: input.siteIDs, + rejectionReason: input.rejectionReason, clientMutationId: clientMutationId.toString(), }, }, diff --git a/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx b/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx index c442de61a0..44440ef1be 100644 --- a/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx +++ b/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx @@ -129,6 +129,9 @@ const UserBanPopoverContainer: FunctionComponent = ({ userID: user.id, commentID: comment.id, rejectExistingComments: !siteBan, + rejectionReason: { + code: GQLREJECTION_REASON_CODE.SPAM, + }, message: getMessage( localeBundles, "common-banEmailTemplate", @@ -145,12 +148,7 @@ const UserBanPopoverContainer: FunctionComponent = ({ storyID: story.id, noEmit: true, reason: { - code: GQLREJECTION_REASON_CODE.OTHER, - detailedExplanation: getMessage( - localeBundles, - "common-userBanned", - "User was banned." - ), + code: GQLREJECTION_REASON_CODE.SPAM, }, }); } From af2269be67dd2f5d1d93521dfaeb59eba9be98b8 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 10:32:16 -0500 Subject: [PATCH 4/8] remove i18n and translation no longer used --- locales/en-US/common.ftl | 4 +--- server/src/core/server/graph/mutators/Users.ts | 2 -- server/src/core/server/services/users/users.ts | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/locales/en-US/common.ftl b/locales/en-US/common.ftl index e456039106..af01dc63cd 100644 --- a/locales/en-US/common.ftl +++ b/locales/en-US/common.ftl @@ -62,6 +62,4 @@ common-moderationReason-detailedExplanation-placeholder = common-moderationReason-customReason = Custom reason (required) common-moderationReason-customReason-placeholder = .placeholder = Add your reason - -common-userBanned = - User was banned. + diff --git a/server/src/core/server/graph/mutators/Users.ts b/server/src/core/server/graph/mutators/Users.ts index de47b64363..141b938909 100644 --- a/server/src/core/server/graph/mutators/Users.ts +++ b/server/src/core/server/graph/mutators/Users.ts @@ -347,7 +347,6 @@ export const Users = (ctx: GraphContext) => ({ ctx.user!, userID, message, - ctx.i18n, rejectExistingComments, siteIDs, rejectionReason, @@ -369,7 +368,6 @@ export const Users = (ctx: GraphContext) => ({ ctx.mailerQueue, ctx.rejectorQueue, ctx.tenant, - ctx.i18n, ctx.user!, userID, message, diff --git a/server/src/core/server/services/users/users.ts b/server/src/core/server/services/users/users.ts index e94322f349..bb5d357f58 100644 --- a/server/src/core/server/services/users/users.ts +++ b/server/src/core/server/services/users/users.ts @@ -1386,7 +1386,6 @@ export async function ban( banner: User, userID: string, message: string, - i18n: I18n, rejectExistingComments: boolean, siteIDs?: string[] | null, rejectionReason?: GQLRejectionReason, @@ -1597,7 +1596,6 @@ export async function updateUserBan( mailer: MailerQueue, rejector: RejectorQueue, tenant: Tenant, - i18n: I18n, banner: User, userID: string, message: string, From 0f8e99b53fe2c6aa5fe2f54e2e9d48e97b923d8f Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 10:41:46 -0500 Subject: [PATCH 5/8] refactor; add comments --- .../core/client/admin/components/BanModal.tsx | 31 ++++++++----------- .../UserBanPopoverContainer.tsx | 29 ++++++++++------- .../core/server/graph/schema/schema.graphql | 8 +++++ 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/client/src/core/client/admin/components/BanModal.tsx b/client/src/core/client/admin/components/BanModal.tsx index 1450d391c7..d16b15589d 100644 --- a/client/src/core/client/admin/components/BanModal.tsx +++ b/client/src/core/client/admin/components/BanModal.tsx @@ -241,6 +241,14 @@ const BanModal: FunctionComponent = ({ }, [viewerIsSingleSiteMod, viewer.moderationScopes]); const onFormSubmit = useCallback(async () => { + const rejectionReason = + rejectExistingComments && dsaFeaturesEnabled + ? { + code: reasonCode!, + detailedExplanation, + customReason: otherCustomReason, + } + : undefined; switch (updateType) { case UpdateType.ALL_SITES: try { @@ -248,13 +256,7 @@ const BanModal: FunctionComponent = ({ userID, // Should be defined because the modal shouldn't open if author is null message: customizeMessage ? emailMessage : getDefaultMessage, rejectExistingComments, - rejectionReason: rejectExistingComments - ? { - code: reasonCode!, - detailedExplanation, - customReason: otherCustomReason, - } - : undefined, + rejectionReason, siteIDs: viewerIsScoped ? viewer?.moderationScopes?.sites?.map(({ id }) => id) : [], @@ -271,13 +273,7 @@ const BanModal: FunctionComponent = ({ banSiteIDs, unbanSiteIDs, rejectExistingComments, - rejectionReason: rejectExistingComments - ? { - code: reasonCode!, - detailedExplanation, - customReason: otherCustomReason, - } - : undefined, + rejectionReason, }); } catch (err) { return { [FORM_ERROR]: err.message }; @@ -334,16 +330,15 @@ const BanModal: FunctionComponent = ({ const requiresSiteBanUpdates = updateType === UpdateType.SPECIFIC_SITES || (updateType === UpdateType.ALL_SITES && viewerIsSingleSiteMod); - // disable if reject all comments doesn't have a reason if dsa is enabled - // also disable if Other reason and not a custom reason included - const requiresRejectionReason = + const requiresRejectionReasonForDSA = rejectExistingComments && !!dsaFeaturesEnabled && (!reasonCode || (reasonCode === GQLREJECTION_REASON_CODE.OTHER && !otherCustomReason)); + const disableForm = (requiresSiteBanUpdates && !pendingSiteBanUpdates) || - requiresRejectionReason; + requiresRejectionReasonForDSA; return ( = ({ onDismiss, view, }) => { - const [{ accessToken }] = useLocal(graphql` - fragment UserBanPopoverContainer_local on Local { - accessToken - } - `); + const [{ accessToken, dsaFeaturesEnabled }] = + useLocal(graphql` + fragment UserBanPopoverContainer_local on Local { + accessToken + dsaFeaturesEnabled + } + `); const { localeBundles, rootURL } = useCoralContext(); const setSpamBanned = useMutation(SetSpamBanned); const reject = useMutation(RejectCommentMutation); @@ -129,9 +131,12 @@ const UserBanPopoverContainer: FunctionComponent = ({ userID: user.id, commentID: comment.id, rejectExistingComments: !siteBan, - rejectionReason: { - code: GQLREJECTION_REASON_CODE.SPAM, - }, + rejectionReason: + dsaFeaturesEnabled && !siteBan + ? { + code: GQLREJECTION_REASON_CODE.SPAM, + } + : undefined, message: getMessage( localeBundles, "common-banEmailTemplate", @@ -147,9 +152,11 @@ const UserBanPopoverContainer: FunctionComponent = ({ commentRevisionID: comment.revision.id, storyID: story.id, noEmit: true, - reason: { - code: GQLREJECTION_REASON_CODE.SPAM, - }, + reason: dsaFeaturesEnabled + ? { + code: GQLREJECTION_REASON_CODE.SPAM, + } + : undefined, }); } } catch (e) { diff --git a/server/src/core/server/graph/schema/schema.graphql b/server/src/core/server/graph/schema/schema.graphql index 0e1fd70b98..e96b8df5cd 100644 --- a/server/src/core/server/graph/schema/schema.graphql +++ b/server/src/core/server/graph/schema/schema.graphql @@ -8876,6 +8876,10 @@ input BanUserInput { """ rejectExistingComments: Boolean + """ + rejectionReason is the reason provided for why any existing comments are being + rejected if DSA is enabled + """ rejectionReason: RejectCommentReasonInput } @@ -8919,6 +8923,10 @@ input UpdateUserBanInput { """ rejectExistingComments: Boolean + """ + rejectionReason is the reason provided for why any existing comments are being + rejected if DSA is enabled + """ rejectionReason: RejectCommentReasonInput """ From bb6b4585a741134ad07ffdd4a6d8b8cf8de65d6b Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 10:43:18 -0500 Subject: [PATCH 6/8] fix missing deps in callbacks --- client/src/core/client/admin/components/BanModal.tsx | 1 + .../Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/client/src/core/client/admin/components/BanModal.tsx b/client/src/core/client/admin/components/BanModal.tsx index d16b15589d..d6ddbb5b75 100644 --- a/client/src/core/client/admin/components/BanModal.tsx +++ b/client/src/core/client/admin/components/BanModal.tsx @@ -315,6 +315,7 @@ const BanModal: FunctionComponent = ({ reasonCode, detailedExplanation, otherCustomReason, + dsaFeaturesEnabled, ]); const { diff --git a/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx b/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx index e94bff73bd..1e76fb391a 100644 --- a/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx +++ b/client/src/core/client/stream/tabs/Comments/Comment/UserBanPopover/UserBanPopoverContainer.tsx @@ -186,6 +186,7 @@ const UserBanPopoverContainer: FunctionComponent = ({ setBanError, siteBan, setSpamBanned, + dsaFeaturesEnabled, ]); if (view === "CONFIRM_BAN") { From c4ef67f3221663f14bc132b2a5a506780af38a2a Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 10:44:30 -0500 Subject: [PATCH 7/8] remove import not used --- server/src/core/server/services/users/users.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/core/server/services/users/users.ts b/server/src/core/server/services/users/users.ts index bb5d357f58..c12ced6067 100644 --- a/server/src/core/server/services/users/users.ts +++ b/server/src/core/server/services/users/users.ts @@ -118,7 +118,6 @@ import { GQLUSER_ROLE, } from "coral-server/graph/schema/__generated__/types"; -import { I18n } from "../i18n"; import { AugmentedRedis } from "../redis"; import { generateAdminDownloadLink, From 7b253e239a2a34e7cd59dcf638ccd4c0bdc225e8 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 12 Dec 2023 11:04:13 -0500 Subject: [PATCH 8/8] dont need i18n in ban user server tests anymore --- server/src/core/server/services/users/users.spec.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/server/src/core/server/services/users/users.spec.ts b/server/src/core/server/services/users/users.spec.ts index 8337f0387c..435df2455d 100644 --- a/server/src/core/server/services/users/users.spec.ts +++ b/server/src/core/server/services/users/users.spec.ts @@ -9,7 +9,6 @@ import { } from "coral-server/test/fixtures"; import { createMockDataCache, - createMockI18n, createMockMailer, createMockMongoContex, createMockRejector, @@ -19,7 +18,6 @@ import { updateRole, updateUserBan } from "./users"; import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types"; import { demoteMember, promoteMember } from "."; -import { I18n } from "../i18n"; describe("updateUserBan", () => { afterEach(jest.clearAllMocks); @@ -37,7 +35,6 @@ describe("updateUserBan", () => { tenantID, role: GQLUSER_ROLE.ADMIN, }); - const i18n = createMockI18n("User was banned."); /* eslint-disable-next-line */ const userService = require("coral-server/models/user"); @@ -55,7 +52,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, commenter, badUser.id, "Test message", @@ -77,7 +73,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - new I18n("en-US"), staff, badUser.id, "Test message", @@ -104,7 +99,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, siteAMod, badUser.id, "Test message", @@ -128,7 +122,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, orgMod, badUser.id, "Test message", @@ -160,7 +153,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, admin, bannedOnSiteA.id, "Test message", @@ -195,7 +187,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, admin, bannedOnSiteB.id, "TEST MESSAGE", @@ -222,7 +213,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, admin, notBannedUser.id, "TEST MESSAGE", @@ -249,7 +239,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, admin, unbannedUser.id, "Test Message", @@ -266,7 +255,6 @@ describe("updateUserBan", () => { mailer, rejector, tenant, - i18n, admin, unbannedUser.id, "Test Message",