({
isQuestionable,
initiateReview
})
| 1 | export 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 | } |
no outgoing calls
no test coverage detected