From 852c4cf504daf53e116ad7a1430253e8d95faa3a Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 10 Feb 2025 20:59:07 -0500 Subject: [PATCH 1/3] feat(posts): posts will display delete option if user is topic owner --- .../templates/partials/topic/post-menu-list.tpl | 10 ++++++++++ src/socket.io/posts/tools.js | 3 +++ 2 files changed, 13 insertions(+) diff --git a/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl b/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl index 07642ec..6599da7 100644 --- a/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl +++ b/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl @@ -62,6 +62,16 @@ {{{ end }}} +{{{ if posts.display_topic_owner_tools }}} +{{{ if !posts.selfPost}}} +
  • + + [[topic:delete]] + +
  • +{{{end}}} +{{{end}}} + {{{ if !posts.deleted }}} {{{ if posts.display_history}}}
  • diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js index 44b4882..5e195ac 100644 --- a/src/socket.io/posts/tools.js +++ b/src/socket.io/posts/tools.js @@ -2,6 +2,7 @@ const nconf = require('nconf'); +const topics = require('../../topics'); const db = require('../../database'); const posts = require('../../posts'); const flags = require('../../flags'); @@ -36,6 +37,7 @@ 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; @@ -43,6 +45,7 @@ module.exports = function (SocketPosts) { 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; From 3ef289e3738517a46ca495871a3337f9f3600f7f Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 10 Feb 2025 21:07:51 -0500 Subject: [PATCH 2/3] feat(posts): added a flag option to posts under the user's topic (currently has a pencil icon) --- .../templates/partials/topic/post-menu-list.tpl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl b/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl index 6599da7..4a38de2 100644 --- a/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl +++ b/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl @@ -64,6 +64,11 @@ {{{ if posts.display_topic_owner_tools }}} {{{ if !posts.selfPost}}} +
  • + + [[topic:flag]] + +
  • [[topic:delete]] From d651234ffe3c5c62b745221aa03bcb133c36ca76 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 10 Feb 2025 21:10:26 -0500 Subject: [PATCH 3/3] fix: removed flag feature as it is a part of a different issue --- .../templates/partials/topic/post-menu-list.tpl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl b/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl index 4a38de2..6599da7 100644 --- a/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl +++ b/nodebb-theme-harmony/templates/partials/topic/post-menu-list.tpl @@ -64,11 +64,6 @@ {{{ if posts.display_topic_owner_tools }}} {{{ if !posts.selfPost}}} -
  • - - [[topic:flag]] - -
  • [[topic:delete]]