From 9ef2d8307afa152d1393501c85af2266924d8c3d Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sat, 18 Apr 2026 20:29:47 +0900 Subject: [PATCH] #294 --- 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