Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sightengine.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ function makeClient(api_user, api_secret) {
});
};

client.text = (text, lang, opt_countries, callback) => {
const url = endpoint + '/1.0/text/check.json';
const mode = _models?.[0] || 'standard';
const data = { text, lang, opt_countries, mode, 'callback_url': callback, 'api_user': apiUser, 'api_secret': apiSecret };
const querystring = encodeQueryData(data);

return fetch(url + '?' + querystring, { headers: { 'user-agent': 'SE-SDK-NODEJS' + version } }).then((res) => {
return res.json();
}).catch((error) => {
return error;
});
};

client.feedback = (model, modelClass, image) => {
var url = endpoint + '1.0/feedback.json'

Expand Down
14 changes: 12 additions & 2 deletions tests.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,15 @@ describe('video sync moderation', () => {
})
})



describe('text moderation', () => {
it('should return success', () => {
return sightengine
.check(['standard'])
.text('You are such a slut')
.then(result => {
assert.equal('success', result.status)
assert.equal('discriminatory', result?.profanity?.matches?.type)
assert.equal('slut', result?.profanity?.matches?.match)
})
})
})