Fix profanity filter admin UI API endpoints
- Corrected API endpoint URLs from /api/admin/profanity/words to /api/admin/profanity-words - Fixed profanity test endpoint from /api/admin/profanity/test to /api/admin/test-profanity - Updated data handling to match actual API response format - Fixed profanity test results display to match API analysis structure - All CRUD operations for profanity words now working correctly
This commit is contained in:
parent
b8e1bc9aa8
commit
e32dfd849f
1 changed files with 9 additions and 8 deletions
|
@ -514,7 +514,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (!profanityTableBody) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/admin/profanity/words', {
|
||||
const response = await fetch('/api/admin/profanity-words', {
|
||||
headers: { 'Authorization': `Bearer ${authToken}` }
|
||||
});
|
||||
|
||||
|
@ -526,7 +526,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
displayProfanityWords(data.words || []);
|
||||
displayProfanityWords(data || []);
|
||||
} else {
|
||||
console.error('Failed to load profanity words:', data.error);
|
||||
profanityTableBody.innerHTML = '<tr><td colspan="6">Failed to load words</td></tr>';
|
||||
|
@ -563,7 +563,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
|
||||
async function addProfanityWord(word, severity, category) {
|
||||
try {
|
||||
const response = await fetch('/api/admin/profanity/words', {
|
||||
const response = await fetch('/api/admin/profanity-words', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -598,7 +598,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (!resultsDiv) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/admin/profanity/test', {
|
||||
const response = await fetch('/api/admin/test-profanity', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -610,12 +610,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
if (data.isProfane) {
|
||||
if (data.analysis && data.analysis.hasProfanity) {
|
||||
resultsDiv.className = 'test-results profane';
|
||||
resultsDiv.innerHTML = `
|
||||
<strong>⚠️ Profanity Detected!</strong><br>
|
||||
Detected words: ${data.detectedWords.map(w => `<code>${escapeHtml(w)}</code>`).join(', ')}<br>
|
||||
Filtered text: "${escapeHtml(data.filteredText)}"
|
||||
Detected words: ${data.analysis.matches.map(m => `<code>${escapeHtml(m.word)}</code>`).join(', ')}<br>
|
||||
Severity: ${data.analysis.severity}<br>
|
||||
Filtered text: "${escapeHtml(data.filtered)}"
|
||||
`;
|
||||
} else {
|
||||
resultsDiv.className = 'test-results clean';
|
||||
|
@ -637,7 +638,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (!confirm('Are you sure you want to delete this word?')) return;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/admin/profanity/words/${wordId}`, {
|
||||
const response = await fetch(`/api/admin/profanity-words/${wordId}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Authorization': `Bearer ${authToken}` }
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue