-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CORL-2948] emit moderation actions #4377
Changes from 8 commits
f4676c5
36fe116
dd43095
9f32e94
00f3340
21491ac
11895b7
9504b97
6e9bb23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming field |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,9 +102,10 @@ export interface ExternalModerationRequest { | |
tenantDomain: string; | ||
} | ||
|
||
// BOOKMARK: (marcushaddon) do we need a new type to maintain type safety with joi? | ||
export type ExternalModerationResponse = Partial< | ||
Pick<PhaseResult, "actions" | "status" | "tags"> | ||
>; | ||
Pick<PhaseResult, "status" | "tags"> | ||
> & { actions: PhaseResult["commentActions"] }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because our public API for external moderation phases still accepts the |
||
|
||
const ExternalModerationResponseSchema = Joi.object().keys({ | ||
actions: Joi.array().items( | ||
|
@@ -267,6 +268,19 @@ async function processPhase( | |
return validateResponse(body); | ||
} | ||
|
||
/** | ||
* Our external API still just has a concept of "actions", while | ||
* internally we distinguish beteween "moderationActions" and "commentActions" | ||
*/ | ||
const mapActions = ( | ||
response: ExternalModerationResponse | ||
): Partial<PhaseResult> => { | ||
return { | ||
...response, | ||
commentActions: response.actions, | ||
}; | ||
}; | ||
|
||
export const external: IntermediateModerationPhase = async (ctx) => { | ||
// Check to see if any custom moderation phases have been defined, if there is | ||
// none, exit now. | ||
|
@@ -317,8 +331,10 @@ export const external: IntermediateModerationPhase = async (ctx) => { | |
}, | ||
}); | ||
|
||
const mappedResponse = mapActions(response); | ||
|
||
// Merge the results in. If we're finished, return now! | ||
const finished = mergePhaseResult(response, result); | ||
const finished = mergePhaseResult(mappedResponse, result); | ||
if (finished) { | ||
return result; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aggregating
commentActions
instead ofactions
.moderationAction
is a single object rather than an array, and isn't aggregated because Moderation Actions set a status on the comment, and so short circuit the pipeline.