mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 00:01:03 +08:00
nono keywords into the kidunfriendlycontent.json file. Oh, and most of it is sourced from you guessed it LINE Today & Taiwan's garbage news corps >_<
18 lines
566 B
TypeScript
18 lines
566 B
TypeScript
import NewsAnalyzer from "~/components/newsAnalyzer";
|
|
const newsAnalyzer = new NewsAnalyzer();
|
|
async function checkUnsafeContent(title: string) {
|
|
try {
|
|
const req = await fetch("/api/contentcheck/kidunfriendlycontent");
|
|
const res = await req.json();
|
|
const patterns = res.words.map((word) => new RegExp(word, "i"));
|
|
console.log(patterns);
|
|
newsAnalyzer.setSensitivePatterns(patterns);
|
|
const kidfriendly = newsAnalyzer.isKidFriendly(title);
|
|
return !kidfriendly;
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
}
|
|
|
|
export default checkUnsafeContent;
|