MCPcopy Create free account
hub / github.com/dev-mastery/comments-api / makeIsQuestionable

Function makeIsQuestionable

src/is-questionable/is-questionable.js:1–48  ·  view source on GitHub ↗
({
  pipe,
  issueHttpRequest,
  querystring
})

Source from the content-addressed store, hash-verified

1export default function makeIsQuestionable ({
2 pipe,
3 issueHttpRequest,
4 querystring
5}) {
6 return async function isQuestionable ({
7 author,
8 browser,
9 createdOn,
10 ip,
11 modifiedOn,
12 referrer,
13 testOnly,
14 text
15 } = {}) {
16 const callModerationApi = pipe(
17 buildModerationApiCommand,
18 issueHttpRequest,
19 normalizeModerationApiResponse
20 )
21 const callSpamApi = pipe(
22 buildAkismetApiCommand,
23 issueHttpRequest,
24 normalizeAkismetApiResponse
25 )
26
27 try {
28 const [inappropriate, spam] = await Promise.all([
29 callModerationApi(text),
30 callSpamApi({
31 author,
32 browser,
33 createdOn,
34 ip,
35 modifiedOn,
36 querystring,
37 referrer,
38 testOnly,
39 text
40 })
41 ])
42 return inappropriate || spam
43 } catch (e) {
44 console.log(e)
45 return true
46 }
47 }
48}
49export function buildModerationApiCommand (text) {
50 return {
51 method: 'post',

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected