Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
9015c2d6
Unverified
Commit
9015c2d6
authored
1 year ago
by
Claire
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Change profile updates to be sent to recently-mentioned servers (#24852)
parent
2c2d9249
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/account_reach_finder.rb
+8
-1
8 additions, 1 deletion
app/lib/account_reach_finder.rb
spec/lib/account_reach_finder_spec.rb
+53
-0
53 additions, 0 deletions
spec/lib/account_reach_finder_spec.rb
with
61 additions
and
1 deletion
app/lib/account_reach_finder.rb
+
8
−
1
View file @
9015c2d6
...
...
@@ -6,7 +6,7 @@ class AccountReachFinder
end
def
inboxes
(
followers_inboxes
+
reporters_inboxes
+
relay_inboxes
).
uniq
(
followers_inboxes
+
reporters_inboxes
+
recently_mentioned_inboxes
+
relay_inboxes
).
uniq
end
private
...
...
@@ -19,6 +19,13 @@ class AccountReachFinder
Account
.
where
(
id:
@account
.
targeted_reports
.
select
(
:account_id
)).
inboxes
end
def
recently_mentioned_inboxes
cutoff_id
=
Mastodon
::
Snowflake
.
id_at
(
2
.
days
.
ago
,
with_random:
false
)
recent_statuses
=
@account
.
statuses
.
recent
.
where
(
id:
cutoff_id
...
).
limit
(
200
)
Account
.
joins
(
:mentions
).
where
(
mentions:
{
status:
recent_statuses
}).
inboxes
.
take
(
2000
)
end
def
relay_inboxes
Relay
.
enabled
.
pluck
(
:inbox_url
)
end
...
...
This diff is collapsed.
Click to expand it.
spec/lib/account_reach_finder_spec.rb
0 → 100644
+
53
−
0
View file @
9015c2d6
# frozen_string_literal: true
require
'rails_helper'
RSpec
.
describe
AccountReachFinder
do
let
(
:account
)
{
Fabricate
(
:account
)
}
let
(
:follower1
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://example.com/inbox-1'
)
}
let
(
:follower2
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://example.com/inbox-2'
)
}
let
(
:follower3
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://foo.bar/users/a/inbox'
,
shared_inbox_url:
'https://foo.bar/inbox'
)
}
let
(
:mentioned1
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://foo.bar/users/b/inbox'
,
shared_inbox_url:
'https://foo.bar/inbox'
)
}
let
(
:mentioned2
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://example.com/inbox-3'
)
}
let
(
:mentioned3
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://example.com/inbox-4'
)
}
let
(
:unrelated_account
)
{
Fabricate
(
:account
,
protocol: :activitypub
,
inbox_url:
'https://example.com/unrelated-inbox'
)
}
before
do
follower1
.
follow!
(
account
)
follower2
.
follow!
(
account
)
follower3
.
follow!
(
account
)
Fabricate
(
:status
,
account:
account
).
tap
do
|
status
|
status
.
mentions
<<
Mention
.
new
(
account:
follower1
)
status
.
mentions
<<
Mention
.
new
(
account:
mentioned1
)
end
Fabricate
(
:status
,
account:
account
)
Fabricate
(
:status
,
account:
account
).
tap
do
|
status
|
status
.
mentions
<<
Mention
.
new
(
account:
mentioned2
)
status
.
mentions
<<
Mention
.
new
(
account:
mentioned3
)
end
Fabricate
(
:status
).
tap
do
|
status
|
status
.
mentions
<<
Mention
.
new
(
account:
unrelated_account
)
end
end
describe
'#inboxes'
do
it
'includes the preferred inbox URL of followers'
do
expect
(
described_class
.
new
(
account
).
inboxes
).
to
include
(
*
[
follower1
,
follower2
,
follower3
].
map
(
&
:preferred_inbox_url
))
end
it
'includes the preferred inbox URL of recently-mentioned accounts'
do
expect
(
described_class
.
new
(
account
).
inboxes
).
to
include
(
*
[
mentioned1
,
mentioned2
,
mentioned3
].
map
(
&
:preferred_inbox_url
))
end
it
'does not include the inbox of unrelated users'
do
expect
(
described_class
.
new
(
account
).
inboxes
).
to_not
include
(
unrelated_account
.
preferred_inbox_url
)
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment