Compare commits

..

5 Commits

Author SHA1 Message Date
みてるぞ 2eec2df65b Merge branch 'main' into feature/308 2026-04-18 05:43:20 +09:00
みてるぞ f4ee3070d6 #308 2026-04-18 05:39:37 +09:00
みてるぞ 9b46e97eaf #308 2026-04-18 05:19:54 +09:00
みてるぞ 1a02ced17d #308 2026-04-16 23:00:35 +09:00
みてるぞ badb280dc3 #308 2026-04-14 23:54:34 +09:00
2 changed files with 3 additions and 6 deletions
@@ -33,8 +33,7 @@ class NicoTagsController < ApplicationController
return head :bad_request if tag.category != 'nico' return head :bad_request if tag.category != 'nico'
linked_tag_names = params[:tags].to_s.split(' ') 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' } return head :bad_request if linked_tags.any? { |t| t.category == 'nico' }
tag.linked_tags = linked_tags tag.linked_tags = linked_tags
+2 -4
View File
@@ -98,9 +98,7 @@ class Tag < ApplicationRecord
@niconico ||= find_or_create_by_tag_name!('ニコニコ', category: :meta) @niconico ||= find_or_create_by_tag_name!('ニコニコ', category: :meta)
end end
def self.normalise_tags tag_names, with_tagme: true, def self.normalise_tags tag_names, with_tagme: true, deny_nico: true
with_no_deerjikist: true,
deny_nico: true
if deny_nico && tag_names.any? { |n| n.downcase.start_with?('nico:') } if deny_nico && tag_names.any? { |n| n.downcase.start_with?('nico:') }
raise NicoTagNormalisationError raise NicoTagNormalisationError
end end
@@ -114,7 +112,7 @@ class Tag < ApplicationRecord
end end
tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme) tags << Tag.tagme if with_tagme && tags.size < 10 && tags.none?(Tag.tagme)
tags << Tag.no_deerjikist if with_no_deerjikist && tags.all? { |t| !(t.deerjikist?) } tags << Tag.no_deerjikist if tags.all? { |t| !(t.deerjikist?) }
tags.uniq(&:id) tags.uniq(&:id)
end end