handle duplicates
This commit is contained in:
parent
60baa74a56
commit
14b89d1e71
3 changed files with 55 additions and 0 deletions
|
@ -22,6 +22,7 @@ class ActivityLogAudienceHelper
|
||||||
return ['to', 'bto', 'cc', 'bcc']
|
return ['to', 'bto', 'cc', 'bcc']
|
||||||
.map { |target| actors(activity_log_event.data[target]) }
|
.map { |target| actors(activity_log_event.data[target]) }
|
||||||
.flatten
|
.flatten
|
||||||
|
.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
43
spec/fixtures/activity_log_events/inbound-with-duplicate-recipients.json
vendored
Normal file
43
spec/fixtures/activity_log_events/inbound-with-duplicate-recipients.json
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"timestamp":"2022-12-08T17:12:38Z",
|
||||||
|
"type": "inbound",
|
||||||
|
"path": "https://example.com/inbox",
|
||||||
|
"data": {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"actor": "https://other.org/users/bob/",
|
||||||
|
"id": "https://other.org/users/bob/statuses/109473290785654613/activity",
|
||||||
|
"object": {
|
||||||
|
"attributedTo": "https://other.org/users/bob/",
|
||||||
|
"content": "A post to selected audiences",
|
||||||
|
"id": "https://other.org/users/bob/statuses/109473290785654613",
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public",
|
||||||
|
"https://example.com/users/first-to",
|
||||||
|
"https://example.com/users/first-to",
|
||||||
|
"https://example.com/users/second-to"
|
||||||
|
],
|
||||||
|
"bto": "https://example.com/users/first-to",
|
||||||
|
"cc": [
|
||||||
|
"https://example.com/users/second-to"
|
||||||
|
],
|
||||||
|
"bcc": [
|
||||||
|
"https://example.com/users/first-to"
|
||||||
|
],
|
||||||
|
"type": "Note"
|
||||||
|
},
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public",
|
||||||
|
"https://example.com/users/first-to",
|
||||||
|
"https://example.com/users/first-to",
|
||||||
|
"https://example.com/users/second-to"
|
||||||
|
],
|
||||||
|
"bto": "https://example.com/users/first-to",
|
||||||
|
"cc": [
|
||||||
|
"https://example.com/users/second-to"
|
||||||
|
],
|
||||||
|
"bcc": [
|
||||||
|
"https://example.com/users/first-to"
|
||||||
|
],
|
||||||
|
"type": "Create"
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,6 +73,17 @@ RSpec.describe ActivityLogAudienceHelper do
|
||||||
'second_follower',
|
'second_follower',
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'removes duplicates from audience' do
|
||||||
|
Rails.configuration.x.web_domain = 'example.com'
|
||||||
|
inbound_event = activity_log_event_fixture('inbound-with-duplicate-recipients.json')
|
||||||
|
|
||||||
|
expect(ActivityLogAudienceHelper.audience(inbound_event)).to match_array([
|
||||||
|
'first-to',
|
||||||
|
'second-to'
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue