diff --git a/app/models/admin/ng_rule.rb b/app/models/admin/ng_rule.rb index 8746457b808725..54ca39b4c9d0cd 100644 --- a/app/models/admin/ng_rule.rb +++ b/app/models/admin/ng_rule.rb @@ -176,7 +176,7 @@ def value_over_threshold?(_reason, value, expected) end def detect_keyword?(text, arr) - Admin::NgRule.detect_keyword?(text, arr) + Admin::NgRule.detect_keyword?(text, arr, local: @account.local?) end class << self @@ -184,14 +184,15 @@ def string_to_array(text) text.delete("\r").split("\n") end - def detect_keyword(text, arr) + def detect_keyword(text, arr, local: true) arr = string_to_array(arr) if arr.is_a?(String) + text = PlainTextFormatter.new(text, false).to_s unless local arr.detect { |word| include?(text, word) ? word : nil } end - def detect_keyword?(text, arr) - detect_keyword(text, arr).present? + def detect_keyword?(text, arr, local: true) + detect_keyword(text, arr, local: local).present? end def include?(text, word) diff --git a/app/models/admin/ng_word.rb b/app/models/admin/ng_word.rb index 2a961d290349be..871909e316b0bf 100644 --- a/app/models/admin/ng_word.rb +++ b/app/models/admin/ng_word.rb @@ -3,12 +3,14 @@ class Admin::NgWord class << self def reject?(text, **options) + text = PlainTextFormatter.new(text, false).to_s if options[:uri].present? hit_word = ng_words.detect { |word| include?(text, word) ? word : nil } record!(:ng_words, text, hit_word, options) if hit_word.present? hit_word.present? end def stranger_mention_reject?(text, **options) + text = PlainTextFormatter.new(text, false).to_s if options[:uri].present? hit_word = ng_words_for_stranger_mention.detect { |word| include?(text, word) ? word : nil } record!(:ng_words_for_stranger_mention, text, hit_word, options) if hit_word.present? hit_word.present? diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index f5137b9fe64b2a..5c668f1e3abdcf 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -1802,7 +1802,7 @@ def activity_for_object(json) end context 'when not contains ng words' do - let(:content) { 'ohagi, world!' } + let(:content) { 'ohagi, world! OH GOOD' } it 'creates status' do expect(sender.statuses.first).to_not be_nil @@ -2052,7 +2052,7 @@ def activity_for_object(json) context 'when ng rule is set' do let(:custom_before) { true } - let(:content) { 'Lorem ipsum' } + let(:content) { 'Lorem ipsum GOOD LINK' } let(:object_json) do { id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,