mirror of
https://github.com/wassname/talk.git
synced 2026-08-01 13:00:55 +08:00
chore: rename accept comment to approve comment (#2341)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import TenantContext from "coral-server/graph/tenant/context";
|
||||
import { accept, reject } from "coral-server/services/comments/moderation";
|
||||
import { approve, reject } from "coral-server/services/comments/moderation";
|
||||
import {
|
||||
GQLAcceptCommentInput,
|
||||
GQLApproveCommentInput,
|
||||
GQLRejectCommentInput,
|
||||
} from "../schema/__generated__/types";
|
||||
|
||||
export const Actions = (ctx: TenantContext) => ({
|
||||
acceptComment: (input: GQLAcceptCommentInput) =>
|
||||
accept(ctx.mongo, ctx.redis, ctx.tenant, {
|
||||
approveComment: (input: GQLApproveCommentInput) =>
|
||||
approve(ctx.mongo, ctx.redis, ctx.tenant, {
|
||||
commentID: input.commentID,
|
||||
commentRevisionID: input.commentRevisionID,
|
||||
moderatorID: ctx.user!.id,
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { GQLAcceptCommentPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
|
||||
import { moderationQueuesResolver } from "./ModerationQueues";
|
||||
|
||||
export const AcceptCommentPayload: GQLAcceptCommentPayloadTypeResolver = {
|
||||
moderationQueues: moderationQueuesResolver,
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { GQLApproveCommentPayloadTypeResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
|
||||
import { moderationQueuesResolver } from "./ModerationQueues";
|
||||
|
||||
export const ApproveCommentPayload: GQLApproveCommentPayloadTypeResolver = {
|
||||
moderationQueues: moderationQueuesResolver,
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
AcceptCommentPayloadToModerationQueuesResolver,
|
||||
ApproveCommentPayloadToModerationQueuesResolver,
|
||||
GQLModerationQueuesTypeResolver,
|
||||
QueryToModerationQueuesResolver,
|
||||
RejectCommentPayloadToModerationQueuesResolver,
|
||||
@@ -89,7 +89,7 @@ export const sharedModerationInputResolver = async (
|
||||
*/
|
||||
export const moderationQueuesResolver:
|
||||
| QueryToModerationQueuesResolver
|
||||
| AcceptCommentPayloadToModerationQueuesResolver
|
||||
| ApproveCommentPayloadToModerationQueuesResolver
|
||||
| RejectCommentPayloadToModerationQueuesResolver = async (
|
||||
source,
|
||||
args,
|
||||
|
||||
@@ -83,8 +83,8 @@ export const Mutation: Required<GQLMutationTypeResolver<void>> = {
|
||||
story: await ctx.mutators.Stories.scrape(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
acceptComment: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Actions.acceptComment(input),
|
||||
approveComment: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Actions.approveComment(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
rejectComment: async (source, { input }, ctx) => ({
|
||||
|
||||
@@ -2,7 +2,7 @@ import Cursor from "coral-server/graph/common/scalars/cursor";
|
||||
import Time from "coral-server/graph/common/scalars/time";
|
||||
import { GQLResolver } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
|
||||
import { AcceptCommentPayload } from "./AcceptCommentPayload";
|
||||
import { ApproveCommentPayload } from "./ApproveCommentPayload";
|
||||
import { AuthIntegrations } from "./AuthIntegrations";
|
||||
import { BanStatus } from "./BanStatus";
|
||||
import { BanStatusHistory } from "./BanStatusHistory";
|
||||
@@ -31,7 +31,7 @@ import { User } from "./User";
|
||||
import { UserStatus } from "./UserStatus";
|
||||
|
||||
const Resolvers: GQLResolver = {
|
||||
AcceptCommentPayload,
|
||||
ApproveCommentPayload,
|
||||
AuthIntegrations,
|
||||
BanStatus,
|
||||
BanStatusHistory,
|
||||
|
||||
@@ -1560,9 +1560,9 @@ enum COMMENT_STATUS {
|
||||
NONE
|
||||
|
||||
"""
|
||||
The comment has been accepted by a moderator.
|
||||
The comment has been approved by a moderator.
|
||||
"""
|
||||
ACCEPTED
|
||||
APPROVED
|
||||
|
||||
"""
|
||||
The comment has been rejected by a moderator.
|
||||
@@ -1894,9 +1894,9 @@ type CommentStatusCounts {
|
||||
NONE: Int!
|
||||
|
||||
"""
|
||||
The comment has been accepted by a moderator.
|
||||
The comment has been approved by a moderator.
|
||||
"""
|
||||
ACCEPTED: Int!
|
||||
APPROVED: Int!
|
||||
|
||||
"""
|
||||
The comment has been rejected by a moderator.
|
||||
@@ -3516,17 +3516,17 @@ type ScrapeStoryPayload {
|
||||
}
|
||||
|
||||
##################
|
||||
# acceptComment
|
||||
# approveComment
|
||||
##################
|
||||
|
||||
input AcceptCommentInput {
|
||||
input ApproveCommentInput {
|
||||
"""
|
||||
commentID is the ID of the Comment that was accepted.
|
||||
commentID is the ID of the Comment that was approved.
|
||||
"""
|
||||
commentID: ID!
|
||||
|
||||
"""
|
||||
commentRevisionID is the ID of the CommentRevision that is being accepted.
|
||||
commentRevisionID is the ID of the CommentRevision that is being approved.
|
||||
"""
|
||||
commentRevisionID: ID!
|
||||
|
||||
@@ -3536,9 +3536,9 @@ input AcceptCommentInput {
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
type AcceptCommentPayload {
|
||||
type ApproveCommentPayload {
|
||||
"""
|
||||
comment is the Comment that was accepted.
|
||||
comment is the Comment that was approved.
|
||||
"""
|
||||
comment: Comment
|
||||
|
||||
@@ -4213,9 +4213,9 @@ type Mutation {
|
||||
@auth(roles: [ADMIN, MODERATOR])
|
||||
|
||||
"""
|
||||
acceptComment will mark the Comment as ACCEPTED.
|
||||
approveComment will mark the Comment as APPROVED.
|
||||
"""
|
||||
acceptComment(input: AcceptCommentInput!): AcceptCommentPayload!
|
||||
approveComment(input: ApproveCommentInput!): ApproveCommentPayload!
|
||||
@auth(roles: [MODERATOR, ADMIN])
|
||||
|
||||
"""
|
||||
|
||||
@@ -6,5 +6,5 @@ import { GQLCOMMENT_STATUS } from "coral-server/graph/tenant/schema/__generated_
|
||||
*/
|
||||
export const VISIBLE_STATUSES = [
|
||||
GQLCOMMENT_STATUS.NONE,
|
||||
GQLCOMMENT_STATUS.ACCEPTED,
|
||||
GQLCOMMENT_STATUS.APPROVED,
|
||||
];
|
||||
|
||||
@@ -305,7 +305,7 @@ export type EditCommentInput = Pick<
|
||||
const EDITABLE_STATUSES = [
|
||||
GQLCOMMENT_STATUS.NONE,
|
||||
GQLCOMMENT_STATUS.PREMOD,
|
||||
GQLCOMMENT_STATUS.ACCEPTED,
|
||||
GQLCOMMENT_STATUS.APPROVED,
|
||||
];
|
||||
|
||||
export function validateEditable(
|
||||
|
||||
@@ -23,7 +23,7 @@ export function createEmptyCommentModerationQueueCounts(): CommentModerationQueu
|
||||
|
||||
export function createEmptyCommentStatusCounts(): CommentStatusCounts {
|
||||
return {
|
||||
[GQLCOMMENT_STATUS.ACCEPTED]: 0,
|
||||
[GQLCOMMENT_STATUS.APPROVED]: 0,
|
||||
[GQLCOMMENT_STATUS.NONE]: 0,
|
||||
[GQLCOMMENT_STATUS.PREMOD]: 0,
|
||||
[GQLCOMMENT_STATUS.REJECTED]: 0,
|
||||
|
||||
@@ -38,7 +38,7 @@ export async function createStoryCountIndexes(mongo: Db) {
|
||||
* statuses.
|
||||
*/
|
||||
export interface CommentStatusCounts {
|
||||
[GQLCOMMENT_STATUS.ACCEPTED]: number;
|
||||
[GQLCOMMENT_STATUS.APPROVED]: number;
|
||||
[GQLCOMMENT_STATUS.NONE]: number;
|
||||
[GQLCOMMENT_STATUS.PREMOD]: number;
|
||||
[GQLCOMMENT_STATUS.REJECTED]: number;
|
||||
@@ -208,7 +208,7 @@ export function mergeCommentStatusCount(
|
||||
// Because the CommentStatusCounts are not indexable, it should be accessed
|
||||
// by walking the structure.
|
||||
switch (status) {
|
||||
case GQLCOMMENT_STATUS.ACCEPTED:
|
||||
case GQLCOMMENT_STATUS.APPROVED:
|
||||
case GQLCOMMENT_STATUS.NONE:
|
||||
case GQLCOMMENT_STATUS.PREMOD:
|
||||
case GQLCOMMENT_STATUS.REJECTED:
|
||||
@@ -239,7 +239,7 @@ export function calculateTotalCommentCount(
|
||||
// Because the CommentStatusCounts are not indexable, it should be accessed
|
||||
// by walking the structure.
|
||||
switch (status) {
|
||||
case GQLCOMMENT_STATUS.ACCEPTED:
|
||||
case GQLCOMMENT_STATUS.APPROVED:
|
||||
case GQLCOMMENT_STATUS.NONE:
|
||||
case GQLCOMMENT_STATUS.PREMOD:
|
||||
case GQLCOMMENT_STATUS.REJECTED:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { GQLCOMMENT_STATUS } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { calculateCountsDiff } from "./counts";
|
||||
|
||||
it("allows transition from NONE to ACCEPTED", () => {
|
||||
it("allows transition from NONE to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.NONE, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -49,11 +49,11 @@ it("allows transition from NONE to FLAGGED*", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from FLAGGED* to ACCEPTED", () => {
|
||||
it("allows transition from FLAGGED* to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.NONE, actionCounts: { FLAG: 1 } },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: { FLAG: 1 } }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: { FLAG: 1 } }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -81,11 +81,11 @@ it("allows transition from FLAGGED* to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from PREMOD to ACCEPTED", () => {
|
||||
it("allows transition from PREMOD to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.PREMOD, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -113,11 +113,11 @@ it("allows transition from PREMOD to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from SYSTEM_WITHHELD to ACCEPTED", () => {
|
||||
it("allows transition from SYSTEM_WITHHELD to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.SYSTEM_WITHHELD, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -145,10 +145,10 @@ it("allows transition from SYSTEM_WITHHELD to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from ACCEPTED to REJECTED", () => {
|
||||
it("allows transition from APPROVED to REJECTED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.REJECTED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
@@ -161,11 +161,11 @@ it("allows transition from ACCEPTED to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from REJECTED to ACCEPTED", () => {
|
||||
it("allows transition from REJECTED to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.REJECTED, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: 0,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { GQLCOMMENT_STATUS } from "coral-server/graph/tenant/schema/__generated__/types";
|
||||
import { calculateCountsDiff } from "./counts";
|
||||
|
||||
it("allows transition from NONE to ACCEPTED", () => {
|
||||
it("allows transition from NONE to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.NONE, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -49,11 +49,11 @@ it("allows transition from NONE to FLAGGED*", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from FLAGGED* to ACCEPTED", () => {
|
||||
it("allows transition from FLAGGED* to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.NONE, actionCounts: { FLAG: 1 } },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: { FLAG: 1 } }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: { FLAG: 1 } }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -81,11 +81,11 @@ it("allows transition from FLAGGED* to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from PREMOD to ACCEPTED", () => {
|
||||
it("allows transition from PREMOD to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.PREMOD, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -113,11 +113,11 @@ it("allows transition from PREMOD to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from SYSTEM_WITHHELD to ACCEPTED", () => {
|
||||
it("allows transition from SYSTEM_WITHHELD to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.SYSTEM_WITHHELD, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: -1,
|
||||
@@ -145,10 +145,10 @@ it("allows transition from SYSTEM_WITHHELD to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from ACCEPTED to REJECTED", () => {
|
||||
it("allows transition from APPROVED to REJECTED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.REJECTED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
@@ -161,11 +161,11 @@ it("allows transition from ACCEPTED to REJECTED", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows transition from REJECTED to ACCEPTED", () => {
|
||||
it("allows transition from REJECTED to APPROVED", () => {
|
||||
expect(
|
||||
calculateCountsDiff(
|
||||
{ status: GQLCOMMENT_STATUS.REJECTED, actionCounts: {} },
|
||||
{ status: GQLCOMMENT_STATUS.ACCEPTED, actionCounts: {} }
|
||||
{ status: GQLCOMMENT_STATUS.APPROVED, actionCounts: {} }
|
||||
)
|
||||
).toEqual({
|
||||
total: 0,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { calculateCountsDiff } from "./counts";
|
||||
export type Moderate = Omit<CreateCommentModerationActionInput, "status">;
|
||||
|
||||
const moderate = (
|
||||
status: GQLCOMMENT_STATUS.ACCEPTED | GQLCOMMENT_STATUS.REJECTED
|
||||
status: GQLCOMMENT_STATUS.APPROVED | GQLCOMMENT_STATUS.REJECTED
|
||||
) => async (
|
||||
mongo: Db,
|
||||
redis: AugmentedRedis,
|
||||
@@ -98,6 +98,6 @@ const moderate = (
|
||||
return result.comment;
|
||||
};
|
||||
|
||||
export const accept = moderate(GQLCOMMENT_STATUS.ACCEPTED);
|
||||
export const approve = moderate(GQLCOMMENT_STATUS.APPROVED);
|
||||
|
||||
export const reject = moderate(GQLCOMMENT_STATUS.REJECTED);
|
||||
|
||||
@@ -25,7 +25,7 @@ describe("compose", () => {
|
||||
});
|
||||
|
||||
it("handles when it returns a status", async () => {
|
||||
const status = GQLCOMMENT_STATUS.ACCEPTED;
|
||||
const status = GQLCOMMENT_STATUS.APPROVED;
|
||||
const enhanced = compose([() => ({ status })]);
|
||||
|
||||
await expect(enhanced(context)).resolves.toEqual({
|
||||
@@ -38,7 +38,7 @@ describe("compose", () => {
|
||||
});
|
||||
|
||||
it("merges the metadata", async () => {
|
||||
const status = GQLCOMMENT_STATUS.ACCEPTED;
|
||||
const status = GQLCOMMENT_STATUS.APPROVED;
|
||||
const enhanced = compose([
|
||||
() => ({ metadata: { first: true } }),
|
||||
() => ({ status, metadata: { second: true } }),
|
||||
@@ -55,7 +55,7 @@ describe("compose", () => {
|
||||
});
|
||||
|
||||
it("merges actions", async () => {
|
||||
const status = GQLCOMMENT_STATUS.ACCEPTED;
|
||||
const status = GQLCOMMENT_STATUS.APPROVED;
|
||||
|
||||
const flags = [
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ export const staff: IntermediateModerationPhase = ({
|
||||
}): IntermediatePhaseResult | void => {
|
||||
if (author.role !== GQLUSER_ROLE.COMMENTER) {
|
||||
return {
|
||||
status: GQLCOMMENT_STATUS.ACCEPTED,
|
||||
status: GQLCOMMENT_STATUS.APPROVED,
|
||||
tags: [
|
||||
{
|
||||
type: COMMENT_TAG_TYPE.STAFF,
|
||||
|
||||
Reference in New Issue
Block a user