mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
[CORL-224] Flag Details (#2293)
* feat: flag details * fix: review * feat: implement flag details in admin * test: test flag details
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import Context from "talk-server/graph/tenant/context";
|
||||
import {
|
||||
CommentActionConnectionInput,
|
||||
retrieveCommentActionConnection,
|
||||
} from "talk-server/models/action/comment";
|
||||
|
||||
export default (ctx: Context) => ({
|
||||
connection: ({ first = 10, after, filter }: CommentActionConnectionInput) =>
|
||||
retrieveCommentActionConnection(ctx.mongo, ctx.tenant.id, {
|
||||
first,
|
||||
after,
|
||||
filter,
|
||||
}),
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import Context from "talk-server/graph/tenant/context";
|
||||
|
||||
import Auth from "./Auth";
|
||||
import CommentActions from "./CommentActions";
|
||||
import CommentModerationActions from "./CommentModerationActions";
|
||||
import Comments from "./Comments";
|
||||
import Stories from "./Stories";
|
||||
@@ -8,6 +9,7 @@ import Users from "./Users";
|
||||
|
||||
export default (ctx: Context) => ({
|
||||
Auth: Auth(ctx),
|
||||
CommentActions: CommentActions(ctx),
|
||||
CommentModerationActions: CommentModerationActions(ctx),
|
||||
Stories: Stories(ctx),
|
||||
Comments: Comments(ctx),
|
||||
|
||||
@@ -5,7 +5,10 @@ import {
|
||||
GQLComment,
|
||||
GQLCommentTypeResolver,
|
||||
} from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { decodeActionCounts } from "talk-server/models/action/comment";
|
||||
import {
|
||||
ACTION_TYPE,
|
||||
decodeActionCounts,
|
||||
} from "talk-server/models/action/comment";
|
||||
import * as comment from "talk-server/models/comment";
|
||||
import { getLatestRevision } from "talk-server/models/comment";
|
||||
import { createConnection } from "talk-server/models/helpers/connection";
|
||||
@@ -64,6 +67,15 @@ export const Comment: GQLCommentTypeResolver<comment.Comment> = {
|
||||
: createConnection(),
|
||||
// Action Counts are encoded, decode them for use with the GraphQL system.
|
||||
actionCounts: c => decodeActionCounts(c.actionCounts),
|
||||
flags: ({ id }, { first = 10, after }, ctx) =>
|
||||
ctx.loaders.CommentActions.connection({
|
||||
first,
|
||||
after,
|
||||
filter: {
|
||||
actionType: ACTION_TYPE.FLAG,
|
||||
commentID: id,
|
||||
},
|
||||
}),
|
||||
viewerActionPresence: (c, input, ctx) =>
|
||||
ctx.user ? ctx.loaders.Comments.retrieveMyActionPresence.load(c.id) : null,
|
||||
parentCount: c => (c.parentID ? c.grandparentIDs.length + 1 : 0),
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { GQLFlagTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import * as actions from "talk-server/models/action/comment";
|
||||
|
||||
export const Flag: GQLFlagTypeResolver<actions.CommentAction> = {
|
||||
flagger: ({ userID }, args, ctx) => {
|
||||
if (userID) {
|
||||
return ctx.loaders.Users.user.load(userID);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
};
|
||||
@@ -13,6 +13,7 @@ import { CommentModerationAction } from "./CommentModerationAction";
|
||||
import { CommentRevision } from "./CommentRevision";
|
||||
import { DisableCommenting } from "./DisableCommenting";
|
||||
import { FacebookAuthIntegration } from "./FacebookAuthIntegration";
|
||||
import { Flag } from "./Flag";
|
||||
import { GoogleAuthIntegration } from "./GoogleAuthIntegration";
|
||||
import { ModerationQueue } from "./ModerationQueue";
|
||||
import { ModerationQueues } from "./ModerationQueues";
|
||||
@@ -42,6 +43,7 @@ const Resolvers: GQLResolver = {
|
||||
Cursor,
|
||||
DisableCommenting,
|
||||
FacebookAuthIntegration,
|
||||
Flag,
|
||||
GoogleAuthIntegration,
|
||||
ModerationQueue,
|
||||
ModerationQueues,
|
||||
|
||||
@@ -182,6 +182,54 @@ type FlagReasonActionCounts {
|
||||
COMMENT_DETECTED_SUSPECT_WORD: Int!
|
||||
}
|
||||
|
||||
type Flag {
|
||||
"""
|
||||
flagger is the User that created the Flag. If this is null, then the system
|
||||
created the Flag.
|
||||
"""
|
||||
flagger: User
|
||||
|
||||
"""
|
||||
reason is the selected reason why the Flag is being created.
|
||||
"""
|
||||
reason: COMMENT_FLAG_REASON!
|
||||
|
||||
"""
|
||||
additionalDetails stores information from the User as to why the Flag was
|
||||
created or is relevant.
|
||||
"""
|
||||
additionalDetails: String
|
||||
}
|
||||
|
||||
type FlagEdge {
|
||||
"""
|
||||
node is the Flag for this edge.
|
||||
"""
|
||||
node: Flag!
|
||||
|
||||
"""
|
||||
cursor is used in pagination.
|
||||
"""
|
||||
cursor: Cursor!
|
||||
}
|
||||
|
||||
type FlagsConnection {
|
||||
"""
|
||||
edges are a subset of FlagEdge's.
|
||||
"""
|
||||
edges: [FlagEdge!]!
|
||||
|
||||
"""
|
||||
nodes is a list of Flags.
|
||||
"""
|
||||
nodes: [Flag!]!
|
||||
|
||||
"""
|
||||
pageInfo is information to aid in pagination.
|
||||
"""
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
"""
|
||||
FlagActionCounts stores all the counts for the counts for the flag action on a
|
||||
given item and the reason counts.
|
||||
@@ -1690,6 +1738,12 @@ type Comment {
|
||||
"""
|
||||
actionCounts: ActionCounts!
|
||||
|
||||
"""
|
||||
flags is the actual Flags that were left by the Users or the system.
|
||||
"""
|
||||
flags(first: Int = 10, after: Cursor): FlagsConnection!
|
||||
@auth(roles: [ADMIN, MODERATOR])
|
||||
|
||||
"""
|
||||
viewerActionPresence stores the presence information for all the actions
|
||||
left by the current User on this Comment.
|
||||
|
||||
Reference in New Issue
Block a user