Skip to content

Commit

Permalink
Merge pull request #16 from CMU-313/TopicOwnerDeletePermissions
Browse files Browse the repository at this point in the history
Added feature that allows topic owners to access a delete option for posts under their topic (src/socket.io/posts/tools.js & nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl)
  • Loading branch information
jonassoh authored Feb 11, 2025
2 parents efc2876 + d651234 commit c0c4abd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
</li>
{{{ end }}}

{{{ if posts.display_topic_owner_tools }}}
{{{ if !posts.selfPost}}}
<li {{{ if posts.deleted }}}hidden{{{ end }}}>
<a class="dropdown-item rounded-1 d-flex align-items-center gap-2" component="post/delete" role="menuitem" href="#" class="{{{ if posts.deleted }}}hidden{{{ end }}}">
<span class="menu-icon"><i class="fa fa-fw text-secondary fa-trash-o"></i></span> [[topic:delete]]
</a>
</li>
{{{end}}}
{{{end}}}

{{{ if !posts.deleted }}}
{{{ if posts.display_history}}}
<li>
Expand Down
3 changes: 3 additions & 0 deletions src/socket.io/posts/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const nconf = require('nconf');

const topics = require('../../topics');
const db = require('../../database');
const posts = require('../../posts');
const flags = require('../../flags');
Expand Down Expand Up @@ -36,13 +37,15 @@ module.exports = function (SocketPosts) {
});

const postData = results.posts;
const topicsData = await topics.getTopicDataByPid(data.pid);
postData.absolute_url = `${nconf.get('url')}/post/${data.pid}`;
postData.bookmarked = results.bookmarked;
postData.selfPost = socket.uid && socket.uid === postData.uid;
postData.display_edit_tools = results.canEdit.flag;
postData.display_delete_tools = results.canDelete.flag;
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_move_tools = results.isAdmin || results.isModerator;
postData.display_change_owner_tools = results.isAdmin || results.isModerator;
Expand Down

0 comments on commit c0c4abd

Please sign in to comment.