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;
|
if (!profanityTableBody) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/admin/profanity/words', {
|
const response = await fetch('/api/admin/profanity-words', {
|
||||||
headers: { 'Authorization': `Bearer ${authToken}` }
|
headers: { 'Authorization': `Bearer ${authToken}` }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
displayProfanityWords(data.words || []);
|
displayProfanityWords(data || []);
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to load profanity words:', data.error);
|
console.error('Failed to load profanity words:', data.error);
|
||||||
profanityTableBody.innerHTML = '<tr><td colspan="6">Failed to load words</td></tr>';
|
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) {
|
async function addProfanityWord(word, severity, category) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/admin/profanity/words', {
|
const response = await fetch('/api/admin/profanity-words', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -598,7 +598,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
if (!resultsDiv) return;
|
if (!resultsDiv) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/admin/profanity/test', {
|
const response = await fetch('/api/admin/test-profanity', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -610,12 +610,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
if (data.isProfane) {
|
if (data.analysis && data.analysis.hasProfanity) {
|
||||||
resultsDiv.className = 'test-results profane';
|
resultsDiv.className = 'test-results profane';
|
||||||
resultsDiv.innerHTML = `
|
resultsDiv.innerHTML = `
|
||||||
<strong>⚠️ Profanity Detected!</strong><br>
|
<strong>⚠️ Profanity Detected!</strong><br>
|
||||||
Detected words: ${data.detectedWords.map(w => `<code>${escapeHtml(w)}</code>`).join(', ')}<br>
|
Detected words: ${data.analysis.matches.map(m => `<code>${escapeHtml(m.word)}</code>`).join(', ')}<br>
|
||||||
Filtered text: "${escapeHtml(data.filteredText)}"
|
Severity: ${data.analysis.severity}<br>
|
||||||
|
Filtered text: "${escapeHtml(data.filtered)}"
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
resultsDiv.className = 'test-results clean';
|
resultsDiv.className = 'test-results clean';
|
||||||
|
@ -637,7 +638,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
if (!confirm('Are you sure you want to delete this word?')) return;
|
if (!confirm('Are you sure you want to delete this word?')) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/admin/profanity/words/${wordId}`, {
|
const response = await fetch(`/api/admin/profanity-words/${wordId}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: { 'Authorization': `Bearer ${authToken}` }
|
headers: { 'Authorization': `Bearer ${authToken}` }
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue