This commit is contained in:
2026-01-31 14:55:44 +09:00
parent 5dd683bd4f
commit 93f494725d
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -67,9 +67,17 @@ class Tag < ApplicationRecord
@bot ||= find_or_create_by_tag_name!('bot操作', category: :meta) @bot ||= find_or_create_by_tag_name!('bot操作', category: :meta)
end end
def self.video
@video ||= find_or_create_by_tag_name!('動画', category: :meta)
end
def self.niconico
@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, deny_nico: true
if deny_nico && tag_names.any? { |n| n.start_with?('nico:') } if deny_nico && tag_names.any? { |n| n.start_with?('nico:') }
raise NicoTagNormalisationError raise NicoTagNormalisationError
end end
tags = tag_names.map do |name| tags = tag_names.map do |name|
+1 -1
View File
@@ -91,7 +91,7 @@ namespace :nico do
end end
post.save! post.save!
post.resized_thumbnail! post.resized_thumbnail!
sync_post_tags!(post, [Tag.tagme.id]) sync_post_tags!(post, [Tag.tagme.id, Tag.bot.id, Tag.niconico.id, Tag.video.id])
end end
kept_ids = PostTag.kept.where(post_id: post.id).pluck(:tag_id).to_set kept_ids = PostTag.kept.where(post_id: post.id).pluck(:tag_id).to_set