Browse Source

#294

feature/294
みてるぞ 12 hours ago
parent
commit
9ef2d8307a
2 changed files with 6 additions and 3 deletions
  1. +2
    -1
      backend/app/controllers/nico_tags_controller.rb
  2. +4
    -2
      backend/app/models/tag.rb

+ 2
- 1
backend/app/controllers/nico_tags_controller.rb View File

@@ -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


+ 4
- 2
backend/app/models/tag.rb View File

@@ -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



Loading…
Cancel
Save