mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Avoid render not_found
in api/v1/tags
This commit is contained in:
parent
25f1a515f8
commit
9c992c3dc1
|
@ -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! :follow, :write, :'write:follows' }, only: [:follow, :unfollow]
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:feature, :unfeature]
|
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:feature, :unfeature]
|
||||||
before_action :require_user!, except: :show
|
before_action :require_user!, except: :show
|
||||||
|
before_action :verify_tag_format
|
||||||
before_action :set_or_create_tag
|
before_action :set_or_create_tag
|
||||||
|
|
||||||
override_rate_limit_headers :follow, family: :follows
|
override_rate_limit_headers :follow, family: :follows
|
||||||
|
@ -36,9 +37,11 @@ class Api::V1::TagsController < Api::BaseController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_or_create_tag
|
def verify_tag_format
|
||||||
return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id])
|
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])
|
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user