Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled Topic Owners to properly delete posts in their topic #20

Merged
merged 7 commits into from
Feb 27, 2025
3 changes: 2 additions & 1 deletion src/privileges/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ privsPosts.canDelete = async function (pid, uid) {
isMod: posts.isModerator([pid], uid),
isLocked: topics.isLocked(postData.tid),
isOwner: posts.isOwner(pid, uid),
isTopicOwner: topics.isOwner(postData.tid, uid),
'posts:delete': privsPosts.can('posts:delete', pid, uid),
});
results.isMod = results.isMod[0];
Expand All @@ -184,7 +185,7 @@ privsPosts.canDelete = async function (pid, uid) {
return { flag: false, message: `[[error:post-delete-duration-expired, ${meta.config.postDeleteDuration}]]` };
}
const { deleterUid } = postData;
const flag = results['posts:delete'] && ((results.isOwner && (deleterUid === 0 || deleterUid === postData.uid)) || results.isMod);
const flag = results['posts:delete'] && ((results.isOwner && (deleterUid === 0 || deleterUid === postData.uid)) || results.isMod || results.isTopicOwner);
return { flag: flag, message: '[[error:no-privileges]]' };
};

Expand Down
2 changes: 1 addition & 1 deletion src/socket.io/posts/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function (SocketPosts) {
postData.display_purge_tools = results.canPurge;
postData.display_flag_tools = socket.uid && results.canFlag.flag;
postData.display_topic_owner_tools = socket.uid === topicsData.uid;
postData.display_moderator_tools = postData.display_edit_tools || postData.display_delete_tools;
postData.display_moderator_tools = results.isAdmin || results.isModerator;
postData.display_move_tools = results.isAdmin || results.isModerator;
postData.display_change_owner_tools = results.isAdmin || results.isModerator;
postData.display_ip_ban = (results.isAdmin || results.isGlobalMod) && !postData.selfPost;
Expand Down