Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/rejection-reason-models #4382

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions server/src/core/server/graph/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3290,6 +3290,60 @@ enum COMMENT_STATUS {
SYSTEM_WITHHELD
}

enum REJECTION_REASON_CODE {
"""
OFFENSIVE represents a rejection of a comment for being offensive.
"""
OFFENSIVE

"""
ABUSIVE represents a rejection of a comment for being abusive.
"""
ABUSIVE

"""
SPAM represents a rejection of a comment for being spam.
"""
SPAM

"""
BANNED_WORD represents a rejection of a comment for containing a banned word.
"""
BANNED_WORD

"""
AD represents a rejection of a comment for being and ad.
"""
AD

"""
ILLEGAL_CONTENT represents a rejection of a comment for containing illegal content.
"""
ILLEGAL_CONTENT

"""
OTHER is reserved for reasons that arent adequately described by the other options.
"""
OTHER
}

type RejectionReason {
"""
code is the reason that the comment was rejected
"""
code: REJECTION_REASON_CODE!

"""
legalGrounds is the specific laws broken as described by the reporter
"""
legalGrounds: String

"""
detailedExplanation is any additional information the user wishes to provide.
"""
detailedExplanation: String
}

type CommentModerationAction {
id: ID!

Expand All @@ -3314,6 +3368,11 @@ type CommentModerationAction {
"""
moderator: User

"""
reason is the reason the comment was rejected, if it was rejected
"""
reason: RejectionReason

"""
createdAt is the time that the CommentModerationAction was created.
"""
Expand Down Expand Up @@ -6660,6 +6719,23 @@ type ApproveCommentPayload {
# rejectComment
##################

input RejectCommentReasonInput {
"""
code is the enumerated code for the reason the comment is being rejected.
"""
code: REJECTION_REASON_CODE!

"""
legalGrounds is the specific laws broken as described by the reporter.
"""
legalGrounds: String

"""
detailedExplanation is any additional information the user wishes to provide.
"""
detailedExplanation: String
}

input RejectCommentInput {
"""
commentID is the ID of the Comment that was rejected.
Expand All @@ -6675,6 +6751,11 @@ input RejectCommentInput {
clientMutationId is required for Relay support.
"""
clientMutationId: String!

"""
reason is the reason the comment is being rejected if DSA features are enabled.
"""
reason: RejectCommentReasonInput
}

type RejectCommentPayload {
Expand Down
15 changes: 14 additions & 1 deletion server/src/core/server/models/action/moderation/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
} from "coral-server/models/helpers";
import { TenantResource } from "coral-server/models/tenant";

import { GQLCOMMENT_STATUS } from "coral-server/graph/schema/__generated__/types";
import {
GQLCOMMENT_STATUS,
GQLREJECTION_REASON_CODE,
} from "coral-server/graph/schema/__generated__/types";

/**
* CommentModerationAction stores information around a moderation action that
Expand Down Expand Up @@ -41,6 +44,16 @@ export interface CommentModerationAction extends TenantResource {
*/
status: GQLCOMMENT_STATUS;

/**
* reason is the GQLMODERATION_REASON_REASON for the decision, if it is
* a rejection
*/
rejectionReason?: {
reason: GQLREJECTION_REASON_CODE;
legalGrounds?: string;
detailedExplanation?: string;
};

/**
* moderatorID is the ID of the User that created the moderation action. If
* null, it indicates that it was created by the system rather than a User.
Expand Down