Add: #545 NGワード指定で実際に除外された投稿のログ (#561)

This commit is contained in:
KMY(雪あすか) 2024-02-16 17:52:59 +09:00 committed by GitHub
parent 0ca2a73fd2
commit 7421c89431
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 262 additions and 17 deletions

View file

@ -1781,6 +1781,11 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to_not be_nil
end
it 'does not record history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to be_nil
end
end
context 'when hit ng words' do
@ -1789,6 +1794,34 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to be_nil
end
it 'records history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to_not be_nil
expect(history.status_blocked?).to be true
expect(history.within_ng_words?).to be true
expect(history.keyword).to eq ng_words
end
end
context 'when hit ng words but does not public visibility' do
let(:content) { 'hello, world!' }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: content,
}
end
it 'creates status' do
expect(sender.statuses.first).to be_nil
end
it 'records history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to be_nil
end
end
context 'when mention from tags' do
@ -1799,6 +1832,7 @@ RSpec.describe ActivityPub::Activity::Create do
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: content,
to: 'https://www.w3.org/ns/activitystreams#Public',
tag: [
{
type: 'Mention',
@ -1814,6 +1848,11 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to_not be_nil
end
it 'does not record history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to be_nil
end
end
context 'with using ng words for stranger' do
@ -1822,6 +1861,14 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to be_nil
end
it 'records history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to_not be_nil
expect(history.status_blocked?).to be true
expect(history.within_ng_words_for_stranger_mention?).to be true
expect(history.keyword).to eq ng_words_for_stranger_mention
end
end
context 'with using ng words for stranger but receiver is following him' do
@ -1836,6 +1883,11 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to_not be_nil
end
it 'does not record history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to be_nil
end
end
context 'with using ng words for stranger but multiple receivers are partically following him' do
@ -1847,6 +1899,7 @@ RSpec.describe ActivityPub::Activity::Create do
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: content,
to: 'https://www.w3.org/ns/activitystreams#Public',
tag: [
{
type: 'Mention',
@ -1868,6 +1921,14 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to be_nil
end
it 'records history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to_not be_nil
expect(history.status_blocked?).to be true
expect(history.within_ng_words_for_stranger_mention?).to be true
expect(history.keyword).to eq ng_words_for_stranger_mention
end
end
end
@ -1880,6 +1941,7 @@ RSpec.describe ActivityPub::Activity::Create do
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: 'ohagi peers',
to: 'https://www.w3.org/ns/activitystreams#Public',
inReplyTo: ActivityPub::TagManager.instance.uri_for(original_status),
}
end
@ -1888,6 +1950,14 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to be_nil
end
it 'records history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to_not be_nil
expect(history.status_blocked?).to be true
expect(history.within_ng_words_for_stranger_mention?).to be true
expect(history.keyword).to eq ng_words_for_stranger_mention
end
end
context 'with following' do
@ -1901,6 +1971,11 @@ RSpec.describe ActivityPub::Activity::Create do
it 'creates status' do
expect(sender.statuses.first).to_not be_nil
end
it 'does not record history' do
history = NgwordHistory.find_by(uri: object_json[:id])
expect(history).to be_nil
end
end
end
end