MCPcopy
hub / github.com/dev-mastery/comments-api / makeHandleModeration

Function makeHandleModeration

src/use-cases/handle-moderation.js:1–24  ·  view source on GitHub ↗
({
  isQuestionable,
  initiateReview
})

Source from the content-addressed store, hash-verified

1export default function makeHandleModeration ({
2 isQuestionable,
3 initiateReview
4}) {
5 return async function handleModeration ({ comment }) {
6 const shouldModerate = await isQuestionable({
7 text: comment.getText(),
8 ip: comment.getSource().getIp(),
9 browser: comment.getSource().getBrowser(),
10 referrer: comment.getSource().getReferrer(),
11 author: comment.getAuthor(),
12 createdOn: comment.getCreatedOn(),
13 modifiedOn: comment.getModifiedOn()
14 })
15 const moderated = { ...comment }
16 if (shouldModerate) {
17 initiateReview({ id: moderated.getId(), content: moderated.getText() })
18 moderated.unPublish()
19 } else {
20 moderated.publish()
21 }
22 return moderated
23 }
24}

Callers 3

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected