Skip to content

Commit 3f9d073

Browse files
committed
feat: add aiModerated flag to moderateSourcePosts mutation
Add an optional `aiModerated` Boolean parameter to the `moderateSourcePosts` GraphQL mutation. When set to `true`, the mutation merges `{ aiModerated: true }` into the JSONB `flags` column of the moderated posts. This enables traceability for AI-automated moderation decisions vs human ones, used by the squad-moderation automation agent. Changes: - Add `aiModerated` to `SourcePostModerationFlags` type - Add `aiModerated: Boolean` parameter to GraphQL schema - Merge flag into JSONB using existing `updateFlagsStatement` utility
1 parent d39988d commit 3f9d073

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/entity/SourcePostModeration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export enum WarningReason {
5252
}
5353

5454
export type SourcePostModerationFlags = Partial<{
55+
aiModerated: boolean;
5556
vordr: boolean;
5657
warningReason: WarningReason;
5758
dedupKey: string;

src/schema/posts.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,10 @@ export const typeDefs = /* GraphQL */ `
17441744
Moderator message for the post
17451745
"""
17461746
moderatorMessage: String
1747+
"""
1748+
Whether this moderation decision was made by AI
1749+
"""
1750+
aiModerated: Boolean
17471751
): [SourcePostModeration]! @auth
17481752
17491753
"""
@@ -3120,12 +3124,13 @@ export const resolvers: IResolvers<unknown, BaseContext> = {
31203124
status,
31213125
rejectionReason = null,
31223126
moderatorMessage = null,
3127+
aiModerated = false,
31233128
}: {
31243129
postIds: string[];
31253130
} & Pick<
31263131
SourcePostModeration,
31273132
'sourceId' | 'status' | 'rejectionReason' | 'moderatorMessage'
3128-
>,
3133+
> & { aiModerated?: boolean },
31293134
ctx: AuthContext,
31303135
info,
31313136
) => {
@@ -3177,6 +3182,13 @@ export const resolvers: IResolvers<unknown, BaseContext> = {
31773182
update.moderatorMessage = moderatorMessage;
31783183
}
31793184

3185+
if (aiModerated) {
3186+
(update as Record<string, unknown>).flags =
3187+
updateFlagsStatement<SourcePostModeration>({
3188+
aiModerated: true,
3189+
});
3190+
}
3191+
31803192
await ctx.con
31813193
.getRepository(SourcePostModeration)
31823194
.update(

0 commit comments

Comments
 (0)