mirror of
https://github.com/wassname/talk.git
synced 2026-07-01 22:41:01 +08:00
27 lines
614 B
JavaScript
27 lines
614 B
JavaScript
const linkify = require('linkify-it')().tlds(require('tlds'));
|
|
|
|
// This phase checks the comment if it has any links in it if the check is
|
|
// enabled.
|
|
module.exports = (
|
|
ctx,
|
|
comment,
|
|
{ asset: { settings: { premodLinksEnable } } }
|
|
) => {
|
|
if (premodLinksEnable && linkify.test(comment.body)) {
|
|
// Add the flag related to Trust to the comment.
|
|
return {
|
|
status: 'SYSTEM_WITHHELD',
|
|
actions: [
|
|
{
|
|
action_type: 'FLAG',
|
|
user_id: null,
|
|
group_id: 'LINKS',
|
|
metadata: {
|
|
links: comment.body,
|
|
},
|
|
},
|
|
],
|
|
};
|
|
}
|
|
};
|