mirror of
https://github.com/wassname/talk.git
synced 2026-07-25 13:30:59 +08:00
feat: added dontAgree create/delete mutations
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
import TenantContext from "talk-server/graph/tenant/context";
|
||||
import {
|
||||
GQLCreateCommentDontAgreeInput,
|
||||
GQLCreateCommentFlagInput,
|
||||
GQLCreateCommentInput,
|
||||
GQLCreateCommentReactionInput,
|
||||
GQLDeleteCommentDontAgreeInput,
|
||||
GQLDeleteCommentFlagInput,
|
||||
GQLDeleteCommentReactionInput,
|
||||
GQLEditCommentInput,
|
||||
} from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { create, edit } from "talk-server/services/comments";
|
||||
import {
|
||||
createDontAgree,
|
||||
createFlag,
|
||||
createReaction,
|
||||
deleteDontAgree,
|
||||
deleteFlag,
|
||||
deleteReaction,
|
||||
} from "talk-server/services/comments/actions";
|
||||
@@ -48,6 +52,14 @@ export default (ctx: TenantContext) => ({
|
||||
deleteReaction(ctx.mongo, ctx.tenant, ctx.user!, {
|
||||
item_id: input.commentID,
|
||||
}),
|
||||
createDontAgree: (input: GQLCreateCommentDontAgreeInput) =>
|
||||
createDontAgree(ctx.mongo, ctx.tenant, ctx.user!, {
|
||||
item_id: input.commentID,
|
||||
}),
|
||||
deleteDontAgree: (input: GQLDeleteCommentDontAgreeInput) =>
|
||||
deleteDontAgree(ctx.mongo, ctx.tenant, ctx.user!, {
|
||||
item_id: input.commentID,
|
||||
}),
|
||||
createFlag: (input: GQLCreateCommentFlagInput) =>
|
||||
createFlag(ctx.mongo, ctx.tenant, ctx.user!, {
|
||||
item_id: input.commentID,
|
||||
|
||||
@@ -31,6 +31,14 @@ const Mutation: GQLMutationTypeResolver<void> = {
|
||||
comment: await ctx.mutators.Comment.deleteReaction(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
createCommentDontAgree: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Comment.createDontAgree(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
deleteCommentDontAgree: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Comment.deleteDontAgree(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
createCommentFlag: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Comment.createFlag(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
|
||||
@@ -1530,6 +1530,62 @@ type DeleteCommentReactionPayload {
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
##################
|
||||
## createCommentDontAgree
|
||||
##################
|
||||
|
||||
input CreateCommentDontAgreeInput {
|
||||
"""
|
||||
commentID is the Comment's ID that we want to create a DontAgree on.
|
||||
"""
|
||||
commentID: ID!
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
type CreateCommentDontAgreePayload {
|
||||
"""
|
||||
comment is the Comment that the DontAgree was created on.
|
||||
"""
|
||||
comment: Comment
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
##################
|
||||
## deleteCommentDontAgree
|
||||
##################
|
||||
|
||||
input DeleteCommentDontAgreeInput {
|
||||
"""
|
||||
commentID is the Comment's ID that we want to delete a DontAgree on.
|
||||
"""
|
||||
commentID: ID!
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
type DeleteCommentDontAgreePayload {
|
||||
"""
|
||||
comment is the Comment that the DontAgree was deleted on.
|
||||
"""
|
||||
comment: Comment
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
##################
|
||||
## createCommentFlag
|
||||
##################
|
||||
@@ -1629,6 +1685,22 @@ type Mutation {
|
||||
input: CreateCommentReactionInput!
|
||||
): CreateCommentReactionPayload @auth
|
||||
|
||||
"""
|
||||
createCommentDontAgree will create a DontAgree authored by the current logged in
|
||||
User on a Comment.
|
||||
"""
|
||||
createCommentDontAgree(
|
||||
input: CreateCommentDontAgreeInput!
|
||||
): CreateCommentDontAgreePayload @auth
|
||||
|
||||
"""
|
||||
deleteCommentDontAgree will delete a DontAgree authored by the current logged in
|
||||
User on a Comment if it exists.
|
||||
"""
|
||||
deleteCommentDontAgree(
|
||||
input: CreateCommentDontAgreeInput!
|
||||
): CreateCommentDontAgreePayload @auth
|
||||
|
||||
"""
|
||||
createCommentFlag will create a Flag authored by the current logged in User on
|
||||
a given Comment.
|
||||
|
||||
@@ -161,6 +161,38 @@ export async function deleteReaction(
|
||||
});
|
||||
}
|
||||
|
||||
export type CreateCommentDontAgree = Pick<CreateActionInput, "item_id">;
|
||||
|
||||
export async function createDontAgree(
|
||||
mongo: Db,
|
||||
tenant: Tenant,
|
||||
author: User,
|
||||
input: CreateCommentDontAgree
|
||||
) {
|
||||
return addCommentAction(mongo, tenant, {
|
||||
action_type: ACTION_TYPE.DONT_AGREE,
|
||||
item_type: ACTION_ITEM_TYPE.COMMENTS,
|
||||
item_id: input.item_id,
|
||||
user_id: author.id,
|
||||
});
|
||||
}
|
||||
|
||||
export type DeleteCommentDontAgree = Pick<DeleteActionInput, "item_id">;
|
||||
|
||||
export async function deleteDontAgree(
|
||||
mongo: Db,
|
||||
tenant: Tenant,
|
||||
author: User,
|
||||
input: DeleteCommentDontAgree
|
||||
) {
|
||||
return removeCommentAction(mongo, tenant, {
|
||||
action_type: ACTION_TYPE.DONT_AGREE,
|
||||
item_type: ACTION_ITEM_TYPE.COMMENTS,
|
||||
item_id: input.item_id,
|
||||
user_id: author.id,
|
||||
});
|
||||
}
|
||||
|
||||
export type CreateCommentFlag = Pick<CreateActionInput, "item_id"> & {
|
||||
reason: GQLCOMMENT_FLAG_REPORTED_REASON;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user