From 89f4471d2c9ac80b72f4db584ea8e9900172d747 Mon Sep 17 00:00:00 2001 From: Pia B Date: Mon, 8 Jun 2026 18:24:30 +0200 Subject: [PATCH 1/5] add to controller and helper --- app/controllers/admin/tags_controller.rb | 2 ++ app/helpers/admin/action_logs_helper.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index f2c28328f86..e64a5952152 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -17,12 +17,14 @@ module Admin authorize @tag, :show? @time_period = report_range + @action_logs = Admin::ActionLogFilter.new(action_type: :update_tag).results.limit(5) end def update authorize @tag, :update? if @tag.update(tag_params.merge(reviewed_at: Time.now.utc)) + log_action :update, @tag redirect_to admin_tag_path(@tag.id), notice: I18n.t('admin.tags.updated_msg') else @time_period = report_range diff --git a/app/helpers/admin/action_logs_helper.rb b/app/helpers/admin/action_logs_helper.rb index 76edb965a6a..22450be4f2f 100644 --- a/app/helpers/admin/action_logs_helper.rb +++ b/app/helpers/admin/action_logs_helper.rb @@ -37,6 +37,8 @@ module Admin::ActionLogsHelper end when 'Relay' link_to log.human_identifier, admin_relays_path + when 'Tag' + link_to log.human_identifier, admin_tags_path end end From 290debb029d8dcb0fe86fd3356f8683c835d9596 Mon Sep 17 00:00:00 2001 From: Pia B Date: Mon, 8 Jun 2026 18:25:17 +0200 Subject: [PATCH 2/5] add to model --- app/models/admin/action_log_filter.rb | 1 + app/models/tag.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/models/admin/action_log_filter.rb b/app/models/admin/action_log_filter.rb index b912865cc85..1fee59e650b 100644 --- a/app/models/admin/action_log_filter.rb +++ b/app/models/admin/action_log_filter.rb @@ -76,6 +76,7 @@ class Admin::ActionLogFilter update_status: { target_type: 'Status', action: 'update' }.freeze, update_user_role: { target_type: 'UserRole', action: 'update' }.freeze, update_ip_block: { target_type: 'IpBlock', action: 'update' }.freeze, + update_tag: { target_type: 'Tag', action: 'update' }.freeze, unblock_email_account: { target_type: 'Account', action: 'unblock_email' }.freeze, create_username_block: { target_type: 'UsernameBlock', action: 'create' }.freeze, update_username_block: { target_type: 'UsernameBlock', action: 'update' }.freeze, diff --git a/app/models/tag.rb b/app/models/tag.rb index a5fbf2f6837..763df252f02 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -110,6 +110,10 @@ class Tag < ApplicationRecord @history ||= Trends::History.new('tags', id) end + def to_log_human_identifier + "##{display_name}" + end + class << self def find_or_create_by_names(name_or_names) names = Array(name_or_names).map { |str| [normalize_value_for(:name, str), str] }.uniq(&:first) From e2bbb35e1b7408ad25f6ad87ff35ae88e6238920 Mon Sep 17 00:00:00 2001 From: Pia B Date: Mon, 8 Jun 2026 18:25:59 +0200 Subject: [PATCH 3/5] add to view --- app/views/admin/tags/show.html.haml | 11 +++++++++++ config/locales/en-GB.yml | 2 ++ 2 files changed, 13 insertions(+) diff --git a/app/views/admin/tags/show.html.haml b/app/views/admin/tags/show.html.haml index 0c8b2eaec0b..96df006b85a 100644 --- a/app/views/admin/tags/show.html.haml +++ b/app/views/admin/tags/show.html.haml @@ -90,3 +90,14 @@ .actions = f.button :button, t('generic.save_changes'), type: :submit + +- if @tag.persisted? + %hr.spacer/ + + %h3= t('admin.tags.audit_log.title') + - if @action_logs.empty? + %p= t('accounts.nothing_here') + - else + .report-notes + = render partial: 'admin/action_logs/action_log', collection: @action_logs + = link_to t('admin.instances.audit_log.view_all'), admin_action_logs_path(action_type: 'update_tag'), class: 'button' diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 9d535e3af02..847d4a55a71 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -243,6 +243,7 @@ en-GB: update_ip_block: Update IP rule update_report: Update Report update_status: Update Post + update_tag: Update Hashtag update_user_role: Update Role update_username_block: Update Username Rule actions: @@ -313,6 +314,7 @@ en-GB: update_ip_block_html: "%{name} changed rule for IP %{target}" update_report_html: "%{name} updated report %{target}" update_status_html: "%{name} updated post by %{target}" + update_tag_html: "%{name} changed rule for %{target}" update_user_role_html: "%{name} changed %{target} role" update_username_block_html: "%{name} updated rule for usernames containing %{target}" deleted_account: deleted account From 9b521cf2c3577dcb35a26d87d8875c7ca135b649 Mon Sep 17 00:00:00 2001 From: Pia B Date: Tue, 9 Jun 2026 09:16:32 +0200 Subject: [PATCH 4/5] add text resource --- config/locales/en.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 95631bd86b9..e3c7b284082 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1101,6 +1101,8 @@ en: action: Check here for more information message_html: "Your object storage is misconfigured. The privacy of your users is at risk." tags: + audit_log: + title: Recent Audit Logs moderation: not_trendable: Not trendable not_usable: Not usable From 8b1d3b91b77535a761d41aaf8638fdb668ffadde Mon Sep 17 00:00:00 2001 From: Pia B Date: Tue, 9 Jun 2026 15:57:01 +0200 Subject: [PATCH 5/5] add request spec and change selection --- app/controllers/admin/tags_controller.rb | 2 +- app/models/admin/action_log_filter.rb | 2 ++ app/models/tag.rb | 2 +- app/views/admin/tags/show.html.haml | 2 +- spec/requests/admin/tags_spec.rb | 13 +++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index e64a5952152..449422c202f 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -17,7 +17,7 @@ module Admin authorize @tag, :show? @time_period = report_range - @action_logs = Admin::ActionLogFilter.new(action_type: :update_tag).results.limit(5) + @action_logs = Admin::ActionLogFilter.new(target_tag: @tag.formatted_name).results.limit(5) end def update diff --git a/app/models/admin/action_log_filter.rb b/app/models/admin/action_log_filter.rb index 1fee59e650b..02980d06477 100644 --- a/app/models/admin/action_log_filter.rb +++ b/app/models/admin/action_log_filter.rb @@ -117,6 +117,8 @@ class Admin::ActionLogFilter when 'target_domain' normalized_domain = TagManager.instance.normalize_domain(value) latest_action_logs.where(human_identifier: normalized_domain, target_type: INSTANCE_TARGET_TYPES) + when 'target_tag' + latest_action_logs.where(human_identifier: value) else raise Mastodon::InvalidParameterError, "Unknown filter: #{key}" end diff --git a/app/models/tag.rb b/app/models/tag.rb index 763df252f02..6ac34832f8f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -111,7 +111,7 @@ class Tag < ApplicationRecord end def to_log_human_identifier - "##{display_name}" + formatted_name end class << self diff --git a/app/views/admin/tags/show.html.haml b/app/views/admin/tags/show.html.haml index 96df006b85a..ea40801e95e 100644 --- a/app/views/admin/tags/show.html.haml +++ b/app/views/admin/tags/show.html.haml @@ -95,7 +95,7 @@ %hr.spacer/ %h3= t('admin.tags.audit_log.title') - - if @action_logs.empty? + - if @action_logs.nil? %p= t('accounts.nothing_here') - else .report-notes diff --git a/spec/requests/admin/tags_spec.rb b/spec/requests/admin/tags_spec.rb index 653c5bd9356..543102e1ebe 100644 --- a/spec/requests/admin/tags_spec.rb +++ b/spec/requests/admin/tags_spec.rb @@ -15,4 +15,17 @@ RSpec.describe 'Admin Tags' do .to have_http_status(400) end end + + describe 'update tag' do + before { sign_in Fabricate(:admin_user) } + + let(:tag) { Fabricate :tag, name: '#supertag' } + + it 'redirects to tag page and saves log action for tag' do + put admin_tag_path(tag.id, params: { tag: { trendable: true } }) + + expect(response).to have_http_status(302) + expect(Admin::ActionLog.last.human_identifier).to eq(tag.formatted_name) + end + end end