fix(reports): separate readable categories from report content
Store readable category snapshots separately from details and evidence, validate report categories, and preserve context in admin displays and moderation actions. Widen report categories to TEXT and bump the schema to 3.2.0 without legacy data conversion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b2811cc248
commit
b45fd161f0
16 files changed
+797
-75
No files matched your search
+11
-7
@@ -24,7 +24,7 @@
|
||||
|
||||
function getReportCategories() {
|
||||
return (Array.isArray(config.reportCategories) ? config.reportCategories : [])
|
||||
.filter(function (cat) { return cat && cat.name; });
|
||||
.filter(function (cat) { return cat && cat.name && cat.name !== '其他原因'; });
|
||||
}
|
||||
|
||||
function buildReportModalHtml(data, categories) {
|
||||
@@ -226,9 +226,10 @@
|
||||
form.querySelector('[name="report_reason"]').focus();
|
||||
return;
|
||||
}
|
||||
var category = selected.value === 'other' ? null : categories[Number(selected.value)];
|
||||
var reason = category ? String(category.name) : otherInput.value.trim();
|
||||
if (!reason) {
|
||||
var other = selected.value === 'other';
|
||||
var category = other ? '其他原因' : String(categories[Number(selected.value)].name);
|
||||
var explanation = other ? otherInput.value.trim() : '';
|
||||
if (other && !explanation) {
|
||||
showError(reasonError, '请填写举报原因');
|
||||
otherInput.setAttribute('aria-invalid', 'true');
|
||||
otherInput.focus();
|
||||
@@ -238,9 +239,12 @@
|
||||
showError(error, '请等待图片上传完成,或重试、删除上传失败的图片');
|
||||
return;
|
||||
}
|
||||
var content = [];
|
||||
if (explanation) content.push(explanation);
|
||||
var description = descInput.value.trim();
|
||||
if (description) reason += '\n详细描述:\n' + description;
|
||||
if (images.length) reason += '\n图片举证:\n' + images.map(function (image) { return image.url; }).join('\n');
|
||||
if (description) content.push(description);
|
||||
if (images.length) content.push('图片举证:\n' + images.map(function (image) { return image.url; }).join('\n'));
|
||||
var reason = content.join('\n\n');
|
||||
submitting = true;
|
||||
syncState();
|
||||
var toastId = form.id + '-submit-' + (++submitAttempts);
|
||||
@@ -249,7 +253,7 @@
|
||||
window.fetch(API_ROOT + '/report/submit', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': NONCE },
|
||||
body: JSON.stringify({ target_type: data.target_type, target_id: data.target_id, category: category ? category.slug : '', reason: reason }),
|
||||
body: JSON.stringify({ target_type: data.target_type, target_id: data.target_id, category: category, reason: reason }),
|
||||
}).then(function (response) { return response.json(); }).then(function (result) {
|
||||
if (!result || !result.success) throw new Error((result && result.message) || '举报提交失败,请重试');
|
||||
// Submitted evidence belongs to the report even if its dialog has already closed.
|
||||
|
||||
Reference in new issue
Block a user