From d872e7bae324d3343c55ba77891f5d691de8cf77 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Thu, 13 Aug 2026 21:51:01 +0200 Subject: [PATCH] hide tagger name from pub --- src/inc/lib.mjs | 12 ++++++++---- src/inc/routeinc/f0cklib.mjs | 2 +- src/inc/routes/apiv2/tags.mjs | 2 +- views/item-partial-legacy.html | 2 +- views/item-partial-modern.html | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/inc/lib.mjs b/src/inc/lib.mjs index d85df5f..9d5c8e6 100644 --- a/src/inc/lib.mjs +++ b/src/inc/lib.mjs @@ -282,18 +282,22 @@ export default new class { return false; }; - async getTags(itemid) { + async getTags(itemid, session = null) { + const hasSession = !!(session && (typeof session === 'object' ? (session.id || session.user) : session)); const tags = await db` - select "tags".id, "tags".tag, "tags".normalized, "user".user, uo.display_name + select "tags".id, "tags".tag, "tags".normalized${hasSession ? db`, "user".user, uo.display_name` : db``} from "tags_assign" left join "tags" on "tags".id = "tags_assign".tag_id - left join "user" on "user".id = "tags_assign".user_id - left join user_options uo on uo.user_id = "user".id + ${hasSession ? db`left join "user" on "user".id = "tags_assign".user_id left join user_options uo on uo.user_id = "user".id` : db``} where "tags_assign".item_id = ${+itemid} order by (case when "tags".id = 1 then 0 when "tags".id = 2 then 1 when "tags".id = ${cfg.nsfl_tag_id || 3} then 2 else 3 end) asc, "tags".id asc `; for (let t = 0; t < tags.length; t++) { tags[t].badge = this.getBadge(tags[t]); + if (!hasSession) { + delete tags[t].user; + delete tags[t].display_name; + } } return tags; }; diff --git a/src/inc/routeinc/f0cklib.mjs b/src/inc/routeinc/f0cklib.mjs index cd46f4f..8dc7718 100644 --- a/src/inc/routeinc/f0cklib.mjs +++ b/src/inc/routeinc/f0cklib.mjs @@ -852,7 +852,7 @@ export default { // Cheat array should include current item and neighbors, sorted const cheat = [itemid, ...cheatItems.map(i => i.id)].sort((a, b) => a - b); - const tags = await lib.getTags(itemid); + const tags = await lib.getTags(itemid, session); const itemHalls = await db`select h.name, h.slug from halls h join halls_assign ha on ha.hall_id = h.id where ha.item_id = ${itemid}`; const userHallsForItem = user_id ? await db`select uh.name, uh.slug from user_halls uh join user_halls_assign uha on uha.hall_id = uh.id where uha.item_id = ${itemid} and uh.user_id = ${user_id}` diff --git a/src/inc/routes/apiv2/tags.mjs b/src/inc/routes/apiv2/tags.mjs index 3992059..f77eb36 100644 --- a/src/inc/routes/apiv2/tags.mjs +++ b/src/inc/routes/apiv2/tags.mjs @@ -19,7 +19,7 @@ export default router => { return res.json({ success: true, - tags: await lib.getTags(+req.params.postid) + tags: await lib.getTags(+req.params.postid, req.session) }); }); diff --git a/views/item-partial-legacy.html b/views/item-partial-legacy.html index 6cf9da0..23a71f6 100644 --- a/views/item-partial-legacy.html +++ b/views/item-partial-legacy.html @@ -177,7 +177,7 @@ @if(typeof item.tags !== "undefined") @each(item.tags as tag) - + {!! tag.tag !!}@if(is_mod_or_admin) @endif @endeach diff --git a/views/item-partial-modern.html b/views/item-partial-modern.html index 569239f..791fc2b 100644 --- a/views/item-partial-modern.html +++ b/views/item-partial-modern.html @@ -42,7 +42,7 @@ @if(typeof item.tags !== "undefined") @each(item.tags as tag) - + {!! tag.tag !!}@if(is_mod_or_admin) @endif @endeach