From 5c7580d57124556226ea209907622007ea4e46d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BF=E3=81=A6=E3=82=8B=E3=81=9E?= Date: Sun, 19 Apr 2026 16:44:20 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8B=E3=82=B3=E3=82=BF=E3=82=B0=E9=80=A3?= =?UTF-8?q?=E6=90=BA=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3=20(#294)=20(#316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #294 Co-authored-by: miteruzo Reviewed-on: https://git.miteruzo.com/miteruzo/btrc-hub/pulls/316 --- backend/app/controllers/nico_tags_controller.rb | 3 ++- backend/app/models/tag.rb | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/app/controllers/nico_tags_controller.rb b/backend/app/controllers/nico_tags_controller.rb index 2349deb..8bb582c 100644 --- a/backend/app/controllers/nico_tags_controller.rb +++ b/backend/app/controllers/nico_tags_controller.rb @@ -33,7 +33,8 @@ class NicoTagsController < ApplicationController return head :bad_request if tag.category != 'nico' linked_tag_names = params[:tags].to_s.split(' ') - linked_tags = Tag.normalise_tags(linked_tag_names, with_tagme: false) + linked_tags = Tag.normalise_tags(linked_tag_names, with_tagme: false, + with_no_deerjikist: false) return head :bad_request if linked_tags.any? { |t| t.category == 'nico' } tag.linked_tags = linked_tags diff --git a/backend/app/models/tag.rb b/backend/app/models/tag.rb index d4edd8d..dfa83b0 100644 --- a/backend/app/models/tag.rb +++ b/backend/app/models/tag.rb @@ -98,7 +98,9 @@ class Tag < ApplicationRecord @niconico ||= find_or_create_by_tag_name!('ニコニコ', category: :meta) end - def self.normalise_tags tag_names, with_tagme: true, deny_nico: true + def self.normalise_tags tag_names, with_tagme: true, + with_no_deerjikist: true, + deny_nico: true if deny_nico && tag_names.any? { |n| n.downcase.start_with?('nico:') } raise NicoTagNormalisationError end @@ -112,7 +114,7 @@ class Tag < ApplicationRecord end tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme) - tags << Tag.no_deerjikist if tags.all? { |t| !(t.deerjikist?) } + tags << Tag.no_deerjikist if with_no_deerjikist && tags.all? { |t| !(t.deerjikist?) } tags.uniq(&:id) end