Skip to content

Feat: AI moderation report compatibility - #419

Open
Trochonovitz wants to merge 6 commits into
masterfrom
feat/ai-moderation-report-compatibility
Open

Feat: AI moderation report compatibility#419
Trochonovitz wants to merge 6 commits into
masterfrom
feat/ai-moderation-report-compatibility

Conversation

@Trochonovitz

Copy link
Copy Markdown
Contributor

Summary

For integration with the Comments Enterprise plugin, the report table got a separate column describing the report source. Additionally, lifecycle methods have been added to trigger actions after adding a comment, and injection zones have been implemented.

@Trochonovitz Trochonovitz self-assigned this Aug 28, 2026
@Trochonovitz Trochonovitz added the enhancement New feature or request label Aug 28, 2026
Comment thread admin/src/api/schemas.ts
resolved: z.boolean(),
createdAt: z.string(),
updatedAt: z.string().nullable(),
source: z.enum(['USER', 'AI']).nullish(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source: z.enum(['USER', 'AI']).nullish(),
source: originSource.nullish(),

So you don't repeat yourself.

Not super conviced about source name. But don't have better name.

Comment on lines +4 to +8
type CustomInjectionZoneCellProps = {
area: `${string}.${string}.${string}`;
as: 'th' | 'td';
[key: string]: unknown;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type CustomInjectionZoneCellProps = {
area: `${string}.${string}.${string}`;
as: 'th' | 'td';
[key: string]: unknown;
};
type CustomInjectionZoneCellProps = {
area: `${string}.${string}.${string}`;
as: 'th' | 'td';
} & Record<string, unknown>;


type ProviderComponentProps = {
children: ReactNode;
[key: string]: unknown;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. To split visually known from the rest.

}

return components.reduceRight((acc, { name, Component }) => {
const Provider = Component as ComponentType<ProviderComponentProps>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably at least made a TS guard to check if it is a function or a class. Typecast are too much confidence in one spot. IMO.

Comment on lines +117 to +118
{reportByAi && <ReportReasonBadge reason={report.source} />}
<ReportReasonBadge reason={report.reason} />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if operation defeats the purpose of the reason or source I don't know which. ReportReasonBadge's logic is kind of leaky that it maps reason (key?) to a variant. If report was by AI, then I'll just inline "other", "AI" or something. And I would handle it in translation. In this case component is repurposed but put in a detached context. I would refactor the component into two components with base one. Or just made a "AI" badge, or "BOT" badge.

What you have now will work, but it is hacky.

@@ -0,0 +1,4 @@
export enum REPORT_SOURCE {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enums are kind of passé

} from './utils/reactions';
import type { ContentType, LifeCycleEvent, LifeCycleHookName } from '../utils/types';

type Effect<T> = (event: T) => void | Promise<void>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type Effect<T> = (event: T) => void | Promise<void>;
type Effect<T = void> = [T] extends [void] ? () => void | Promise<void> : (event: T) => void | Promise<void>;

It will make it more flexible. And if you want no-params effect you can have it too.

publishedAt: z.string().nullable(),
locale: z.string().nullable(),
related: relatedSchema.nullable().optional(),
source: z.enum(['USER', 'AI']).nullish(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's duplicated here also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants