Make moderation actions atomic and authorized
This commit is contained in:
1 parent
2e74b1505b
commit
c57863fc47
4 files changed
+78
-21
No files matched your search
@@ -49,12 +49,6 @@ function renderAdminReports() {
|
||||
const note = action === 'approve' ? '已删除违规帖子' : '举报不成立';
|
||||
if (action === 'approve' && !confirm('确定要删除该帖子并标记举报为已处理吗?')) return;
|
||||
API.updateReport(id, status, note).then(() => {
|
||||
if (action === 'approve') {
|
||||
const report = reports.find(r => r.id === id);
|
||||
if (report && report.post_id) {
|
||||
API.deletePost(report.post_id).catch(() => {});
|
||||
}
|
||||
}
|
||||
renderAdminReports();
|
||||
}).catch(err => alert('操作失败:' + err.message));
|
||||
});
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ async function renderPostDetail(postId) {
|
||||
<img src="${rAvatar}" class="reply-avatar" />
|
||||
<span class="reply-username" style="cursor:pointer;color:var(--primary);" onclick="switchPage('user','${rUsername}')">${rUsername}</span>
|
||||
<span class="reply-time">${rTime}</span>
|
||||
${currentUser && currentUser.id === r.user_id ? `<button class="btn-sm btn-danger reply-delete-btn" data-replyid="${r.id}">
|
||||
${currentUser && (currentUser.id === r.user_id || currentUser.role === 'admin') ? `<button class="btn-sm btn-danger reply-delete-btn" data-replyid="${r.id}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline;vertical-align:middle;"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
||||
删除
|
||||
</button>` : ''}
|
||||
|
||||
Reference in new issue
Block a user