Skip to content

Commit

Permalink
Merge pull request #4460 from coralproject/develop
Browse files Browse the repository at this point in the history
[8.6.4] Release (`develop` into `main`)
  • Loading branch information
nick-funk authored Dec 13, 2023
2 parents 83b1d4f + 2edb974 commit 5c412f2
Show file tree
Hide file tree
Showing 21 changed files with 429 additions and 23 deletions.
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coralproject/talk",
"version": "8.6.3",
"version": "8.6.4",
"author": "The Coral Project",
"homepage": "https://coralproject.net/",
"sideEffects": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ const markers: Array<
</Localized>
)) ||
null,
(c) =>
(c.status === "PREMOD" &&
c.author &&
c.author.premoderatedBecauseOfEmailAt && (
<Localized id="moderate-marker-preMod-userEmail" key={keyCounter++}>
<Marker color="pending">User email</Marker>
</Localized>
)) ||
null,
(c) =>
(c.revision &&
c.revision.actionCounts.flag.reasons.COMMENT_DETECTED_LINKS && (
Expand Down Expand Up @@ -239,6 +248,9 @@ const enhanced = withFragmentContainer<MarkersContainerProps>({
tags {
code
}
author {
premoderatedBecauseOfEmailAt
}
revision {
actionCounts {
illegal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import EmailDomainConfigContainer from "./EmailDomainConfigContainer";
import ExternalLinksConfigContainer from "./ExternalLinksConfigContainer";
import NewCommentersConfigContainer from "./NewCommentersConfigContainer";
import PerspectiveConfig from "./PerspectiveConfig";
import PremoderateEmailAddressConfig from "./PremoderateEmailAddressConfig";
import PreModerationConfigContainer from "./PreModerationConfigContainer";
import RecentCommentHistoryConfig from "./RecentCommentHistoryConfig";

Expand Down Expand Up @@ -49,6 +50,7 @@ export const ModerationConfigContainer: React.FunctionComponent<Props> = ({
<NewCommentersConfigContainer disabled={submitting} settings={settings} />
<RecentCommentHistoryConfig disabled={submitting} />
<ExternalLinksConfigContainer disabled={submitting} settings={settings} />
<PremoderateEmailAddressConfig disabled={submitting} />
<EmailDomainConfigContainer settings={settings} />
</HorizontalGutter>
);
Expand All @@ -67,6 +69,7 @@ const enhanced = withFragmentContainer<Props>({
...EmailDomainConfigContainer_settings
...ExternalLinksConfigContainer_formValues @relay(mask: false)
...ExternalLinksConfigContainer_settings
...PremoderateEmailAddressConfig_formValues @relay(mask: false)
}
`,
})(ModerationConfigContainer);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Localized } from "@fluent/react/compat";
import React, { FunctionComponent } from "react";
import { graphql } from "react-relay";

import {
FieldSet,
FormField,
FormFieldHeader,
Label,
} from "coral-ui/components/v2";

import ConfigBox from "../../ConfigBox";
import Header from "../../Header";
import HelperText from "../../HelperText";
import OnOffField from "../../OnOffField";

// eslint-disable-next-line no-unused-expressions
graphql`
fragment PremoderateEmailAddressConfig_formValues on Settings {
premoderateEmailAddress {
tooManyPeriods {
enabled
}
}
}
`;

interface Props {
disabled: boolean;
}

const PremoderateEmailAddressConfig: FunctionComponent<Props> = ({
disabled,
}) => {
return (
<ConfigBox
title={
<Localized id="configure-moderation-premoderateEmailAddress-title">
<Header container={<legend />}>Email address</Header>
</Localized>
}
container={<FieldSet />}
>
<FormField container={<FieldSet />}>
<FormFieldHeader>
<Localized id="configure-moderation-premoderateEmailAddress-enabled">
<Label component="legend">
Pre-moderate emails with too many periods
</Label>
</Localized>
<Localized id="configure-moderation-premoderateEmailAddress-enabled-description">
<HelperText>
If a user has three or more periods in the first part of their
email address (before the @), set their status to pre-moderate
comments. Emails with 3 or more periods can have a very high spam
correlation. It can be useful to pro-actively pre-moderate them.
</HelperText>
</Localized>
</FormFieldHeader>
<OnOffField
name="premoderateEmailAddress.tooManyPeriods.enabled"
disabled={disabled}
/>
</FormField>
</ConfigBox>
);
};

export default PremoderateEmailAddressConfig;
4 changes: 2 additions & 2 deletions common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "common",
"version": "8.6.3",
"version": "8.6.4",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions config/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "common",
"version": "8.6.3",
"version": "8.6.4",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
12 changes: 12 additions & 0 deletions locales/en-US/admin.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,17 @@ configure-moderation-emailDomains-confirmDelete = Deleting this email domain wil
configure-moderation-emailDomains-form-description-add = Add a domain and select the action that should be taken when on every new account created using the specified domain.
configure-moderation-emailDomains-form-description-edit = Update the domain or action that should be taken when on every new account using the specified domain.
#### Pre-moderate Email Address Configuration

configure-moderation-premoderateEmailAddress-title = Email address
configure-moderation-premoderateEmailAddress-enabled =
Pre-moderate emails with too many periods
configure-moderation-premoderateEmailAddress-enabled-description =
If a user has three or more periods in the first part of their
email address (before the @), set their status to pre-moderate
comments. Emails with 3 or more periods can have a very high spam
correlation. It can be useful to pro-actively pre-moderate them.
#### Banned Words Configuration
configure-wordList-banned-bannedWordsAndPhrases = Banned words and phrases
configure-wordList-banned-explanation =
Expand Down Expand Up @@ -1029,6 +1040,7 @@ moderate-marker-abusive = Abusive
moderate-marker-newCommenter = New commenter
moderate-marker-repeatPost = Repeat comment
moderate-marker-other = Other
moderate-marker-preMod-userEmail = User email
moderate-markers-details = Details
moderate-flagDetails-latestReports = Latest reports
Expand Down
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coralproject/talk",
"version": "8.6.3",
"version": "8.6.4",
"author": "The Coral Project",
"homepage": "https://coralproject.net/",
"sideEffects": [
Expand Down
19 changes: 18 additions & 1 deletion server/src/core/server/app/handlers/api/auth/local/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ import {
UsernameAlreadyExists,
} from "coral-server/errors";
import { hasEnabledAuthIntegration } from "coral-server/models/tenant";
import { LocalProfile, User } from "coral-server/models/user";
import {
LocalProfile,
premodUser,
PremodUserReason,
User,
} from "coral-server/models/user";
import { create, usernameAlreadyExists } from "coral-server/services/users";
import { sendConfirmationEmail } from "coral-server/services/users/auth";
import { shouldPremodDueToLikelySpamEmail } from "coral-server/services/users/emailPremodFilter";
import { RequestHandler, TenantCoralRequest } from "coral-server/types/express";

import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types";
Expand Down Expand Up @@ -117,6 +123,17 @@ export const signupHandler = ({
now
);

if (shouldPremodDueToLikelySpamEmail(tenant, user)) {
await premodUser(
mongo,
tenant.id,
user.id,
undefined,
now,
PremodUserReason.EmailPremodFilter
);
}

// Send off to the passport handler.
return handleSuccessfulLogin(user, signingConfig, req, res, next);
} catch (err) {
Expand Down
12 changes: 12 additions & 0 deletions server/src/core/server/graph/resolvers/PremoderateEmailAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
GQLPremoderateEmailAddressConfiguration,
GQLPremoderateEmailAddressConfigurationTypeResolver,
} from "coral-server/graph/schema/__generated__/types";

export const PremoderateEmailAddressConfiguration: GQLPremoderateEmailAddressConfigurationTypeResolver<GQLPremoderateEmailAddressConfiguration> =
{
tooManyPeriods: (config) =>
config && config.tooManyPeriods
? config.tooManyPeriods
: { enabled: false },
};
2 changes: 2 additions & 0 deletions server/src/core/server/graph/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { NewCommentersConfiguration } from "./NewCommentersConfiguration";
import { NotificationResolver as Notification } from "./Notification";
import { NotificationDSAReportDetailsResolver as NotificationDSAReportDetails } from "./NotificationDSAReportDetails";
import { OIDCAuthIntegration } from "./OIDCAuthIntegration";
import { PremoderateEmailAddressConfiguration } from "./PremoderateEmailAddress";
import { PremodStatus } from "./PremodStatus";
import { PremodStatusHistory } from "./PremodStatusHistory";
import { Profile } from "./Profile";
Expand Down Expand Up @@ -171,6 +172,7 @@ const Resolvers: GQLResolver = {
YouTubeMediaConfiguration,
LocalAuthIntegration,
AuthenticationTargetFilter,
PremoderateEmailAddressConfiguration,
Notification,
NotificationDSAReportDetails,
DSAConfiguration,
Expand Down
50 changes: 50 additions & 0 deletions server/src/core/server/graph/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,36 @@ type RTEConfiguration {
sarcasm: Boolean!
}

type TooManyPeriodsConfig {
"""
enabled decides whether the too many periods config is enabled or not.
"""
enabled: Boolean!
}

type PremoderateEmailAddressConfiguration {
"""
tooManyPeriods is the configuration for premoderating emails
that have too many periods.
"""
tooManyPeriods: TooManyPeriodsConfig
}

input TooManyPeriodsConfigInput {
"""
enabled decides whether the too many periods config is enabled or not.
"""
enabled: Boolean
}

input PremoderateEmailAddressConfigurationInput {
"""
tooManyPeriods is the configuration for premoderating emails
that have too many periods.
"""
tooManyPeriods: TooManyPeriodsConfigInput
}

enum DSA_METHOD_OF_REDRESS {
NONE
EMAIL
Expand Down Expand Up @@ -2293,6 +2323,12 @@ type Settings @cacheControl(maxAge: 30) {
features and whether they are enabled.
"""
dsa: DSAConfiguration!

"""
premoderateEmailAddress is the configuration for finding specific email
addresses at sign up and premoderating them according to various rules.
"""
premoderateEmailAddress: PremoderateEmailAddressConfiguration
}

################################################################################
Expand Down Expand Up @@ -3219,6 +3255,13 @@ type User {
"""
bio: String

"""
premoderatedBecauseOfEmailAt is set when a user was set to pre-moderated
comments for having an email that was caught by the email pre-moderation
filter.
"""
premoderatedBecauseOfEmailAt: Time @auth(roles: [MODERATOR, ADMIN])

"""
hasNewNotifications returns true if the user has received new notifications
since they last viewed their notifications tab.
Expand Down Expand Up @@ -6421,11 +6464,18 @@ input SettingsInput {
"""
flairBadges: FlairBadgeConfigurationInput


"""
dsa specifies the configuration for DSA European Union moderation and
reporting features.
"""
dsa: DSAConfigurationInput

"""
premoderateEmailAddress is the configuration for finding specific email
addresses at sign up and premoderating them according to various rules.
"""
premoderateEmailAddress: PremoderateEmailAddressConfigurationInput
}

"""
Expand Down
Loading

0 comments on commit 5c412f2

Please sign in to comment.