From 9c992c3dc1fbc4719a2a71182dd240d9e2334669 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 29 Jul 2025 12:36:41 -0400 Subject: [PATCH] Avoid `render not_found` in api/v1/tags --- app/controllers/api/v1/tags_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/tags_controller.rb b/app/controllers/api/v1/tags_controller.rb index 67a4d8ef492..44810b93f9d 100644 --- a/app/controllers/api/v1/tags_controller.rb +++ b/app/controllers/api/v1/tags_controller.rb @@ -4,6 +4,7 @@ class Api::V1::TagsController < Api::BaseController before_action -> { doorkeeper_authorize! :follow, :write, :'write:follows' }, only: [:follow, :unfollow] before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:feature, :unfeature] before_action :require_user!, except: :show + before_action :verify_tag_format before_action :set_or_create_tag override_rate_limit_headers :follow, family: :follows @@ -36,9 +37,11 @@ class Api::V1::TagsController < Api::BaseController private - def set_or_create_tag - return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id]) + def verify_tag_format + not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id]) + end + def set_or_create_tag @tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id]) end end