update wordfilter func
This commit is contained in:
@@ -2831,4 +2831,12 @@ CREATE INDEX IF NOT EXISTS idx_dm_att_expires ON public.dm_attachments(expires
|
|||||||
ALTER TABLE private_messages
|
ALTER TABLE private_messages
|
||||||
ADD COLUMN IF NOT EXISTS edited_at timestamp with time zone DEFAULT NULL;
|
ADD COLUMN IF NOT EXISTS edited_at timestamp with time zone DEFAULT NULL;
|
||||||
|
|
||||||
|
-- Wordfilter Table (Migration 009)
|
||||||
|
CREATE TABLE IF NOT EXISTS public.wordfilter (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
word VARCHAR(255) UNIQUE NOT NULL,
|
||||||
|
replacement VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
||||||
|
);
|
||||||
|
|
||||||
\unrestrict RMNKNzVQLV2ZcwmM3bmhglTot5nRoju9FmRyi3eUMfNy6iJUBfHRIgXnbrpJikG
|
\unrestrict RMNKNzVQLV2ZcwmM3bmhglTot5nRoju9FmRyi3eUMfNy6iJUBfHRIgXnbrpJikG
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<!-- Rule Add Section -->
|
<!-- Rule Add Section -->
|
||||||
<div class="wordfilter-form-container" style="background: rgba(0,0,0,0.2); padding: 20px; border-radius: 6px; margin-bottom: 30px; border: 1px solid rgba(255,255,255,0.05);">
|
<div class="wordfilter-form-container" style="background: rgba(0,0,0,0.2); padding: 20px; border-radius: 6px; margin-bottom: 30px; border: 1px solid rgba(255,255,255,0.05);">
|
||||||
<h4 style="color: var(--accent); margin-top: 0; margin-bottom: 15px;">Create Wordfilter Rule</h4>
|
<h4 style="color: var(--accent); margin-top: 0; margin-bottom: 15px;">Create Wordfilter Rule</h4>
|
||||||
<form id="wordfilter-form" onsubmit="event.preventDefault(); addRule(this);" style="display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap;">
|
<form id="wordfilter-form" onsubmit="event.preventDefault(); window.wordfilterAdmin.addRule(this);" style="display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap;">
|
||||||
<div style="flex: 1; min-width: 200px;">
|
<div style="flex: 1; min-width: 200px;">
|
||||||
<label for="word" style="display: block; margin-bottom: 6px; font-size: 0.9em; color: #ccc;">Target Word</label>
|
<label for="word" style="display: block; margin-bottom: 6px; font-size: 0.9em; color: #ccc;">Target Word</label>
|
||||||
<input type="text" id="word" name="word" required placeholder="Word to match..." style="width: 100%; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 10px; border-radius: 4px; font-size: 1em;">
|
<input type="text" id="word" name="word" required placeholder="Word to match..." style="width: 100%; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); color: #fff; padding: 10px; border-radius: 4px; font-size: 1em;">
|
||||||
@@ -51,6 +51,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
(function() {
|
||||||
|
const escapeHtml = (str) => {
|
||||||
|
if (!str) return '';
|
||||||
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||||
|
};
|
||||||
|
|
||||||
const loadRules = async () => {
|
const loadRules = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/v2/admin/wordfilter');
|
const res = await fetch('/api/v2/admin/wordfilter');
|
||||||
@@ -73,7 +79,7 @@
|
|||||||
'<td data-label="Replacement" style="font-family: monospace; color: #fff;">' + escapeHtml(f.replacement) + '</td>' +
|
'<td data-label="Replacement" style="font-family: monospace; color: #fff;">' + escapeHtml(f.replacement) + '</td>' +
|
||||||
'<td data-label="Created">' + (f.created_at ? new Date(f.created_at).toLocaleString() : '—') + '</td>' +
|
'<td data-label="Created">' + (f.created_at ? new Date(f.created_at).toLocaleString() : '—') + '</td>' +
|
||||||
'<td data-label="Actions" style="text-align: right;">' +
|
'<td data-label="Actions" style="text-align: right;">' +
|
||||||
'<button onclick="deleteRule(' + f.id + ')" class="btn-remove" style="padding: 5px 12px; font-size: 0.85em; border-radius: 4px; border: 0; cursor: pointer;">Delete</button>' +
|
'<button onclick="window.wordfilterAdmin.deleteRule(' + f.id + ')" class="btn-remove" style="padding: 5px 12px; font-size: 0.85em; border-radius: 4px; border: 0; cursor: pointer;">Delete</button>' +
|
||||||
'</td>' +
|
'</td>' +
|
||||||
'</tr>'
|
'</tr>'
|
||||||
).join('');
|
).join('');
|
||||||
@@ -135,13 +141,15 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function escapeHtml(str) {
|
window.wordfilterAdmin = {
|
||||||
if (!str) return '';
|
loadRules,
|
||||||
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
addRule,
|
||||||
}
|
deleteRule
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize view
|
// Initialize view
|
||||||
loadRules();
|
loadRules();
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user