feat: moderation
This commit is contained in:
parent
db9c133bbb
commit
2def8d7a00
6 changed files with 61 additions and 4 deletions
22
website/src/lib/server/moderation.ts
Normal file
22
website/src/lib/server/moderation.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
export async function isNameAppropriate(name: string): Promise<boolean> {
|
||||
try {
|
||||
const response = await fetch('http://localhost:9999', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ name }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Moderation service error:', response.status, response.statusText);
|
||||
return true;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result.appropriate !== false;
|
||||
} catch (error) {
|
||||
console.error('Failed to check name with moderation service:', error);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in a new issue