Fix: 投稿編集時にハッシュタグ拒否のドメインブロックが動作しない問題 (#519)
This commit is contained in:
parent
a686391169
commit
64a149b338
4 changed files with 38 additions and 1 deletions
|
@ -484,6 +484,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignore_hashtags?
|
def ignore_hashtags?
|
||||||
|
return @ignore_hashtags if defined?(@ignore_hashtags)
|
||||||
|
|
||||||
@ignore_hashtags ||= DomainBlock.reject_hashtag?(@account.domain)
|
@ignore_hashtags ||= DomainBlock.reject_hashtag?(@account.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
|
|
||||||
as_array(@json['tag']).each do |tag|
|
as_array(@json['tag']).each do |tag|
|
||||||
if equals_or_includes?(tag['type'], 'Hashtag')
|
if equals_or_includes?(tag['type'], 'Hashtag')
|
||||||
@raw_tags << tag['name'] if tag['name'].present?
|
@raw_tags << tag['name'] if !ignore_hashtags? && tag['name'].present?
|
||||||
elsif equals_or_includes?(tag['type'], 'Mention')
|
elsif equals_or_includes?(tag['type'], 'Mention')
|
||||||
@raw_mentions << tag['href'] if tag['href'].present?
|
@raw_mentions << tag['href'] if tag['href'].present?
|
||||||
elsif equals_or_includes?(tag['type'], 'Emoji')
|
elsif equals_or_includes?(tag['type'], 'Emoji')
|
||||||
|
@ -298,6 +298,12 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
@skip_download ||= DomainBlock.reject_media?(@account.domain)
|
@skip_download ||= DomainBlock.reject_media?(@account.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ignore_hashtags?
|
||||||
|
return @ignore_hashtags if defined?(@ignore_hashtags)
|
||||||
|
|
||||||
|
@ignore_hashtags ||= DomainBlock.reject_hashtag?(@account.domain)
|
||||||
|
end
|
||||||
|
|
||||||
def unsupported_media_type?(mime_type)
|
def unsupported_media_type?(mime_type)
|
||||||
mime_type.present? && !MediaAttachment.supported_mime_types.include?(mime_type)
|
mime_type.present? && !MediaAttachment.supported_mime_types.include?(mime_type)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1344,6 +1344,22 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.tags.map(&:name)).to include('test')
|
expect(status.tags.map(&:name)).to include('test')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with domain-block' do
|
||||||
|
let(:custom_before) { true }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_hashtag: true)
|
||||||
|
subject.perform
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not create status' do
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to_not be_nil
|
||||||
|
expect(status.tags.map(&:name)).to eq []
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with hashtags missing name' do
|
context 'with hashtags missing name' do
|
||||||
|
|
|
@ -310,6 +310,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when reject tags by domain-block' do
|
||||||
|
let(:tags) { [Fabricate(:tag, name: 'hoge'), Fabricate(:tag, name: 'ohagi')] }
|
||||||
|
|
||||||
|
before do
|
||||||
|
Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_hashtag: true)
|
||||||
|
subject.call(status, json, json)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'updates tags' do
|
||||||
|
expect(status.tags.reload.map(&:name)).to eq []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when originally without mentions' do
|
context 'when originally without mentions' do
|
||||||
before do
|
before do
|
||||||
subject.call(status, json, json)
|
subject.call(status, json, json)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue