From 42fb8b54119a59e26db92c6261d46621e11a8009 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Thu, 7 Sep 2023 09:46:40 -0600 Subject: [PATCH 01/25] documentation how `.env` file needs to reside under `server/` --- docs/docs/development.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/docs/development.md b/docs/docs/development.md index ad9c291ec1..6b60076e13 100644 --- a/docs/docs/development.md +++ b/docs/docs/development.md @@ -58,7 +58,13 @@ to start the installation wizard. To see the comment stream goto http://localhost:8080/. -To run linting and tests use the following commands: +### To modify environment variables: + +Place and modify a `.env` file within `server/`. + +Similar to other applications, development environment variables are picked up from a `.env` file. However, since Coral is a mono-repo, you need to create this file within the `server/` folder. This allows Coral's web server to pick up on the configuration at its relative startup root. + +### To run linting and tests use the following commands: ```bash # Run the linters. From c2942229e41b5c586cce853aa6b58039726dfb27 Mon Sep 17 00:00:00 2001 From: Marcus Haddon Date: Wed, 27 Sep 2023 16:03:50 -0700 Subject: [PATCH 02/25] fix true/false mixup in permission map --- client/src/core/client/admin/permissions/story.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/core/client/admin/permissions/story.ts b/client/src/core/client/admin/permissions/story.ts index 49e0273588..973492a6e7 100644 --- a/client/src/core/client/admin/permissions/story.ts +++ b/client/src/core/client/admin/permissions/story.ts @@ -17,7 +17,7 @@ const permissionMap: PermissionMap = { [GQLUSER_ROLE.MODERATOR]: () => true, }, ARCHIVE_STORY: { - [GQLUSER_ROLE.ADMIN]: () => false, + [GQLUSER_ROLE.ADMIN]: () => true, }, }; From 4e55a1f16131bd22447fcb020ae0cc1d618b412a Mon Sep 17 00:00:00 2001 From: Raymon Mens Date: Tue, 10 Oct 2023 16:37:34 +0200 Subject: [PATCH 03/25] Update Dutch translations --- locales/nl-NL/stream.ftl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/locales/nl-NL/stream.ftl b/locales/nl-NL/stream.ftl index a69fa338b6..69c9f2b594 100644 --- a/locales/nl-NL/stream.ftl +++ b/locales/nl-NL/stream.ftl @@ -3,7 +3,7 @@ ## General general-commentsEmbedSection = - .aria-label = Reacties insluiten + .aria-label = Reacties embedden general-moderate = Modereren general-archived = Gearchiveerd @@ -175,7 +175,7 @@ comments-rte-externalImage = comments-remainingCharacters = { $remaining } overgebleven karakters -comments-postCommentFormFake-signInAndJoin = Meld je aan of Registreer je in 1 minuut om een reactie te kunnen plaatsen. +comments-postCommentFormFake-signInAndJoin = Aanmelden registreren om een reactie te kunnen plaatsen. comments-postCommentForm-rteLabel = Plaats een reactie @@ -251,13 +251,13 @@ comments-userPopover-ignore = Negeren comments-userIgnorePopover-ignoreUser = Negeer {$username}? comments-userIgnorePopover-description = Wanneer je een gebruiker negeert, dan worden - alle reacties van deze gebruiker niet meer getoond aan je. + alle reacties van deze gebruiker voor jou verborgen. Je kunt dit later ongedaan maken in je profiel. comments-userIgnorePopover-ignore = Negeren comments-userIgnorePopover-cancel = Annuleren comments-userBanPopover-title = Blokkeer {$username}? -comments-userSiteBanPopover-title = Ban {$username} from this site? +comments-userSiteBanPopover-title = Ban {$username} van deze site? comments-userBanPopover-description = Eenmaal geblokkeerd, zal deze gebruiker niet meer in staat zijn om om reacties te plaatsen. @@ -273,7 +273,7 @@ comments-moderationDropdown-approve = Goedkeuren comments-moderationDropdown-approved = Goedgekeurd comments-moderationDropdown-reject = Afwijzen comments-moderationDropdown-rejected = Afgewezen -comments-moderationDropdown-ban = Blokkeer Gebruiker +comments-moderationDropdown-ban = Blokkeer gebruiker comments-moderationDropdown-siteBan = Site Ban comments-moderationDropdown-banned = Geblokkeerd comments-moderationDropdown-goToModerate = @@ -446,7 +446,7 @@ profile-preferencesTab = Voorkeuren ### Bio profile-bio-title = Bio profile-bio-description = - Schrijf een bio om openbaar weer te geven op je commentaarprofiel. Moet + Schrijf een bio om openbaar weer te geven op je profiel. Moet minder dan 100 tekens bevatten. profile-bio-remove = Verwijderen profile-bio-update = Bijwerken @@ -465,7 +465,7 @@ profile-accountDeletion-cancelAccountDeletion = ### Comment History profile-commentHistory-section = - .aria-label = Reactie Geschiedenis + .aria-label = Eerdere reacties profile-historyComment-commentLabel = Reactie op { $storyTitle } profile-historyComment-viewConversation = Bekijk discussie @@ -542,7 +542,7 @@ profile-account-changePassword = Wijzig wachtwoord profile-account-changePassword-oldPassword = Oud wachtwoord profile-account-changePassword-forgotPassword = Wachtwoord vergeten? profile-account-changePassword-newPassword = Nieuw wachtwoord -profile-account-changePassword-button = Change wachtwoord +profile-account-changePassword-button = Verander wachtwoord profile-account-changePassword-updated = Je wachtwoord is gewijzigd profile-account-changePassword-password = wachtwoord @@ -661,7 +661,7 @@ profile-account-changePassword-change = Wijzigen profile-notificationsTab = Notificaties profile-account-notifications-emailNotifications = E-mail notificaties profile-account-notifications-emailNotifications = E-mail notificaties -profile-account-notifications-receiveWhen = Ontvang notificaties als: +profile-account-notifications-receiveWhen = Ontvang notificaties wanneer: profile-account-notifications-onReply = Mijn reactie een antwoord ontvangt profile-account-notifications-onFeatured = Mijn reactie is opgenomen in de lijst profile-account-notifications-onStaffReplies = Een medewerker reageert op mijn reactie @@ -749,9 +749,9 @@ profile-changeUsername-edit = Bewerk profile-changeUsername-change = Wijzigen .aria-label = Wijzig gebruikernaam profile-changeUsername-heading = Bewerk je gebruikersnaam -profile-changeUsername-heading-changeYourUsername = Change your username -profile-changeUsername-desc = Wijzig de gebruikersnaam die bij al je vroegere en toekomstige reacties zal verschijnen. Gebruikersnamen kunnen gewijzigd worden ééns per { framework-timeago-time }. -profile-changeUsername-desc-text = Wijzig de gebruikersnaam die bij al je vroegere en toekomstige reacties zal verschijnen. Gebruikersnamen kunnen gewijzigd worden ééns per { framework-timeago-time }. +profile-changeUsername-heading-changeYourUsername = Verander je gebruikersnaam +profile-changeUsername-desc = Wijzig de gebruikersnaam die bij al je vroegere en toekomstige reacties zal verschijnen. Gebruikersnamen kunnen ééns per { framework-timeago-time } gewijzigd worden. +profile-changeUsername-desc-text = Wijzig de gebruikersnaam die bij al je vroegere en toekomstige reacties zal verschijnen. Gebruikersnamen kunnen ééns per { framework-timeago-time } gewijzigd worden. profile-changeUsername-current = Huidige gebruikersnaam profile-changeUsername-newUsername-label = Nieuwe gebruikersnaam profile-changeUsername-confirmNewUsername-label = Bevestig nieuwe gebruikersnaam From 19170478dbcd238f71f5edd2ec4491a4b8827125 Mon Sep 17 00:00:00 2001 From: Raymon Mens Date: Tue, 10 Oct 2023 16:41:16 +0200 Subject: [PATCH 04/25] Update stream.ftl --- locales/nl-NL/stream.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/nl-NL/stream.ftl b/locales/nl-NL/stream.ftl index 69c9f2b594..2ee529a239 100644 --- a/locales/nl-NL/stream.ftl +++ b/locales/nl-NL/stream.ftl @@ -175,7 +175,7 @@ comments-rte-externalImage = comments-remainingCharacters = { $remaining } overgebleven karakters -comments-postCommentFormFake-signInAndJoin = Aanmelden registreren om een reactie te kunnen plaatsen. +comments-postCommentFormFake-signInAndJoin = Aanmelden of registreren om een reactie te kunnen plaatsen. comments-postCommentForm-rteLabel = Plaats een reactie From fae0d870ae120b41bab67f575cf7279b73b11206 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Tue, 24 Oct 2023 14:54:42 -0600 Subject: [PATCH 05/25] add COMMENT_LEFT_MODERATION_QUEUE webhook option --- server/src/core/server/events/listeners/webhook.ts | 1 + .../Subscription/commentEnteredModerationQueue.ts | 1 + .../resolvers/Subscription/commentLeftModerationQueue.ts | 1 + server/src/core/server/graph/schema/schema.graphql | 1 + server/src/core/server/services/events/comments.ts | 8 +++++++- 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/src/core/server/events/listeners/webhook.ts b/server/src/core/server/events/listeners/webhook.ts index 2467ae2f36..c42a3373d7 100644 --- a/server/src/core/server/events/listeners/webhook.ts +++ b/server/src/core/server/events/listeners/webhook.ts @@ -17,6 +17,7 @@ export class WebhookCoralEventListener CoralEventType.STORY_CREATED, CoralEventType.COMMENT_CREATED, CoralEventType.COMMENT_REPLY_CREATED, + CoralEventType.COMMENT_LEFT_MODERATION_QUEUE, ]; private readonly queue: WebhookQueue; diff --git a/server/src/core/server/graph/resolvers/Subscription/commentEnteredModerationQueue.ts b/server/src/core/server/graph/resolvers/Subscription/commentEnteredModerationQueue.ts index e40e7c061b..f28d0c8fa0 100644 --- a/server/src/core/server/graph/resolvers/Subscription/commentEnteredModerationQueue.ts +++ b/server/src/core/server/graph/resolvers/Subscription/commentEnteredModerationQueue.ts @@ -17,6 +17,7 @@ export interface CommentEnteredModerationQueueInput extends SubscriptionPayload { queue: GQLMODERATION_QUEUE; commentID: string; + status?: string; storyID: string; siteID: string; section?: string; diff --git a/server/src/core/server/graph/resolvers/Subscription/commentLeftModerationQueue.ts b/server/src/core/server/graph/resolvers/Subscription/commentLeftModerationQueue.ts index 894fdcfc7d..479ff998ec 100644 --- a/server/src/core/server/graph/resolvers/Subscription/commentLeftModerationQueue.ts +++ b/server/src/core/server/graph/resolvers/Subscription/commentLeftModerationQueue.ts @@ -16,6 +16,7 @@ import { export interface CommentLeftModerationQueueInput extends SubscriptionPayload { queue: GQLMODERATION_QUEUE; commentID: string; + status?: string; storyID: string; siteID: string; section?: string; diff --git a/server/src/core/server/graph/schema/schema.graphql b/server/src/core/server/graph/schema/schema.graphql index cf20728d62..e6988429cb 100644 --- a/server/src/core/server/graph/schema/schema.graphql +++ b/server/src/core/server/graph/schema/schema.graphql @@ -1737,6 +1737,7 @@ enum WEBHOOK_EVENT_NAME { STORY_CREATED COMMENT_CREATED COMMENT_REPLY_CREATED + COMMENT_LEFT_MODERATION_QUEUE } type WebhookEndpoint { diff --git a/server/src/core/server/services/events/comments.ts b/server/src/core/server/services/events/comments.ts index 90a08e2438..69c8553859 100644 --- a/server/src/core/server/services/events/comments.ts +++ b/server/src/core/server/services/events/comments.ts @@ -162,12 +162,13 @@ export async function publishCommentFeatured( export async function publishModerationQueueChanges( broker: CoralEventPublisherBroker, moderationQueue: Pick, - comment: Pick + comment: Pick ) { if (moderationQueue.queues.pending === 1) { await CommentEnteredModerationQueueCoralEvent.publish(broker, { queue: GQLMODERATION_QUEUE.PENDING, commentID: comment.id, + status: comment.status, storyID: comment.storyID, siteID: comment.siteID, section: comment.section, @@ -176,6 +177,7 @@ export async function publishModerationQueueChanges( await CommentLeftModerationQueueCoralEvent.publish(broker, { queue: GQLMODERATION_QUEUE.PENDING, commentID: comment.id, + status: comment.status, storyID: comment.storyID, siteID: comment.siteID, section: comment.section, @@ -185,6 +187,7 @@ export async function publishModerationQueueChanges( await CommentEnteredModerationQueueCoralEvent.publish(broker, { queue: GQLMODERATION_QUEUE.REPORTED, commentID: comment.id, + status: comment.status, storyID: comment.storyID, siteID: comment.siteID, section: comment.section, @@ -193,6 +196,7 @@ export async function publishModerationQueueChanges( await CommentLeftModerationQueueCoralEvent.publish(broker, { queue: GQLMODERATION_QUEUE.REPORTED, commentID: comment.id, + status: comment.status, storyID: comment.storyID, siteID: comment.siteID, section: comment.section, @@ -202,6 +206,7 @@ export async function publishModerationQueueChanges( await CommentEnteredModerationQueueCoralEvent.publish(broker, { queue: GQLMODERATION_QUEUE.UNMODERATED, commentID: comment.id, + status: comment.status, storyID: comment.storyID, siteID: comment.siteID, section: comment.section, @@ -210,6 +215,7 @@ export async function publishModerationQueueChanges( await CommentLeftModerationQueueCoralEvent.publish(broker, { queue: GQLMODERATION_QUEUE.UNMODERATED, commentID: comment.id, + status: comment.status, storyID: comment.storyID, siteID: comment.siteID, section: comment.section, From ec8261c37c3324b8a9e1438abb37e9d041e80b82 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Tue, 31 Oct 2023 10:58:52 -0600 Subject: [PATCH 06/25] use tenant locale to translate graphql errors if available previously, it was grabbing the locale from the context only which was always set to en-US by default instead of retrieving from the tenant which has the accurate locale. if the tenant is not available, we simply default back to the context locale to be safe. --- server/src/core/server/graph/plugins/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/core/server/graph/plugins/helpers.ts b/server/src/core/server/graph/plugins/helpers.ts index e5f6c41543..94465e66f2 100644 --- a/server/src/core/server/graph/plugins/helpers.ts +++ b/server/src/core/server/graph/plugins/helpers.ts @@ -101,7 +101,7 @@ function hoistCoralErrorExtensions( } // Get the translation bundle. - const bundle = ctx.i18n.getBundle(ctx.lang); + const bundle = ctx.i18n.getBundle(ctx.tenant ? ctx.tenant.locale : ctx.lang); // Translate the extensions. const extensions = originalError.serializeExtensions(bundle, ctx.id); From d78a70d76ced3c66e57e30af90c8675eb7746a0e Mon Sep 17 00:00:00 2001 From: nick-funk Date: Tue, 31 Oct 2023 11:06:40 -0600 Subject: [PATCH 07/25] add rr.com to the protected email domains --- common/lib/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/common/lib/constants.ts b/common/lib/constants.ts index 112dce5ca8..132723659b 100644 --- a/common/lib/constants.ts +++ b/common/lib/constants.ts @@ -152,6 +152,7 @@ export const PROTECTED_EMAIL_DOMAINS = new Set([ "live.no", "yahoo.no", "hotmail.no", + "rr.com" ]); export const FLAIR_BADGE_NAME_REGEX = "^[\\w.-]+$"; From e7c0e8cca6df7d6c7c6de0c55f024ea4287e6c60 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 7 Nov 2023 14:08:44 -0500 Subject: [PATCH 08/25] only emit sharepopover event once --- .../tabs/Comments/Comment/PermalinkButton/PermalinkPopover.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/core/client/stream/tabs/Comments/Comment/PermalinkButton/PermalinkPopover.tsx b/client/src/core/client/stream/tabs/Comments/Comment/PermalinkButton/PermalinkPopover.tsx index def6f3605e..4376049b95 100644 --- a/client/src/core/client/stream/tabs/Comments/Comment/PermalinkButton/PermalinkPopover.tsx +++ b/client/src/core/client/stream/tabs/Comments/Comment/PermalinkButton/PermalinkPopover.tsx @@ -31,7 +31,7 @@ const PermalinkPopover: FunctionComponent = ({ // Run once. useEffect(() => { emitShowEvent({ commentID }); - }, [emitShowEvent, commentID]); + }, []); const timeout: any = useRef(null); From 22230a58c69872fc23362baab7d13c6311944d61 Mon Sep 17 00:00:00 2001 From: Kathryn Beaty Date: Tue, 7 Nov 2023 14:17:21 -0500 Subject: [PATCH 09/25] emit report popover event; also refactor to FC --- .../Comment/ReportFlow/ReportCommentForm.tsx | 403 +++++++++--------- 1 file changed, 206 insertions(+), 197 deletions(-) diff --git a/client/src/core/client/stream/tabs/Comments/Comment/ReportFlow/ReportCommentForm.tsx b/client/src/core/client/stream/tabs/Comments/Comment/ReportFlow/ReportCommentForm.tsx index ab205a5617..ad744e842d 100644 --- a/client/src/core/client/stream/tabs/Comments/Comment/ReportFlow/ReportCommentForm.tsx +++ b/client/src/core/client/stream/tabs/Comments/Comment/ReportFlow/ReportCommentForm.tsx @@ -1,15 +1,17 @@ import { Localized } from "@fluent/react/compat"; import cn from "classnames"; import { get } from "lodash"; -import React, { FunctionComponent } from "react"; +import React, { FunctionComponent, useEffect } from "react"; import { Field, FieldProps, Form } from "react-final-form"; +import { useViewerEvent } from "coral-framework/lib/events"; import { OnSubmit } from "coral-framework/lib/form"; import { customMessage, validateMaxLength, } from "coral-framework/lib/validation"; import CLASSES from "coral-stream/classes"; +import { ShowReportPopoverEvent } from "coral-stream/events"; import { Flex, RadioButton } from "coral-ui/components/v2"; import { Button, ValidationMessage } from "coral-ui/components/v3"; @@ -51,215 +53,222 @@ export interface FormProps { additionalDetails?: string; } -class ReportCommentForm extends React.Component { - public render() { - const { onCancel, onSubmit, id } = this.props; - return ( -
-
- {({ - handleSubmit, - submitting, - hasValidationErrors, - form, - submitError, - }) => ( - -
- -
Report This Comment
-
- -
- Why are you reporting this comment? -
-
-
    -
  • - - - This comment is offensive - - -
  • -
  • - - - This commenter is being abusive - - -
  • -
  • - - - I disagree with this comment - - -
  • -
  • - - - This looks like an ad or marketing - - -
  • - {this.props.biosEnabled && ( -
  • - - - This commenter's bio is offensive or abusive - - -
  • - )} +const ReportCommentForm: FunctionComponent = ({ + onCancel, + onSubmit, + id, + biosEnabled, +}) => { + const emitReportEvent = useViewerEvent(ShowReportPopoverEvent); + + // Run once. + useEffect(() => { + emitReportEvent({ commentID: id }); + }, []); + + return ( +
    + + {({ + handleSubmit, + submitting, + hasValidationErrors, + form, + submitError, + }) => ( + +
    + +
    Report This Comment
    +
    + +
    + Why are you reporting this comment? +
    +
    +
      +
    • + + + This comment is offensive + + +
    • +
    • + + + This commenter is being abusive + + +
    • +
    • + + + I disagree with this comment + + +
    • +
    • + + + This looks like an ad or marketing + + +
    • + {biosEnabled && (
    • - + - Other + This commenter's bio is offensive or abusive
    • -
    - }} - > - - - -
    - Please leave any additional information that may be helpful - to our moderators. -
    -
    -
    - - - Please restrict your report to 500 characters - - - )} - > - {({ input, meta }) => ( -
    -