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
dbd52910
Commit
dbd52910
authored
7 years ago
by
Eugen Rochko
Browse files
Options
Downloads
Patches
Plain Diff
Fix notifications delivered to wrong pubsub channel, optimized RemoveStatusService,
slightly optimized FanOutOnWriteService again
parent
dea6e47d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/services/fan_out_on_write_service.rb
+5
-4
5 additions, 4 deletions
app/services/fan_out_on_write_service.rb
app/services/notify_service.rb
+1
-1
1 addition, 1 deletion
app/services/notify_service.rb
app/services/remove_status_service.rb
+15
-13
15 additions, 13 deletions
app/services/remove_status_service.rb
with
21 additions
and
18 deletions
app/services/fan_out_on_write_service.rb
+
5
−
4
View file @
dbd52910
...
...
@@ -51,21 +51,22 @@ class FanOutOnWriteService < BaseService
def
render_anonymous_payload
(
status
)
@payload
=
InlineRenderer
.
render
(
status
,
nil
,
'api/v1/statuses/show'
)
@payload
=
Oj
.
dump
(
event: :update
,
payload:
@payload
)
end
def
deliver_to_hashtags
(
status
)
Rails
.
logger
.
debug
"Delivering status
#{
status
.
id
}
to hashtags"
status
.
tags
.
pluck
(
:name
).
each
do
|
hashtag
|
Redis
.
current
.
publish
(
"hashtag:
#{
hashtag
}
"
,
Oj
.
dump
(
event: :update
,
payload:
@payload
)
)
Redis
.
current
.
publish
(
"hashtag:
#{
hashtag
}
:local"
,
Oj
.
dump
(
event: :update
,
payload:
@payload
)
)
if
status
.
account
.
local?
Redis
.
current
.
publish
(
"hashtag:
#{
hashtag
}
"
,
@payload
)
Redis
.
current
.
publish
(
"hashtag:
#{
hashtag
}
:local"
,
@payload
)
if
status
.
local?
end
end
def
deliver_to_public
(
status
)
Rails
.
logger
.
debug
"Delivering status
#{
status
.
id
}
to public timeline"
Redis
.
current
.
publish
(
'public'
,
Oj
.
dump
(
event:
'update'
,
payload:
@payload
)
)
Redis
.
current
.
publish
(
'public:local'
,
Oj
.
dump
(
event:
'update'
,
payload:
@payload
)
)
if
status
.
account
.
local?
Redis
.
current
.
publish
(
'public'
,
@payload
)
Redis
.
current
.
publish
(
'public:local'
,
@payload
)
if
status
.
local?
end
end
This diff is collapsed.
Click to expand it.
app/services/notify_service.rb
+
1
−
1
View file @
dbd52910
...
...
@@ -50,7 +50,7 @@ class NotifyService < BaseService
def
create_notification
@notification
.
save!
return
unless
@notification
.
browserable?
Redis
.
current
.
publish
(
@recipient
.
id
,
Oj
.
dump
(
event: :notification
,
payload:
InlineRenderer
.
render
(
@notification
,
@recipient
,
'api/v1/notifications/show'
)))
Redis
.
current
.
publish
(
"timeline:
#{
@recipient
.
id
}
"
,
Oj
.
dump
(
event: :notification
,
payload:
InlineRenderer
.
render
(
@notification
,
@recipient
,
'api/v1/notifications/show'
)))
end
def
send_email
...
...
This diff is collapsed.
Click to expand it.
app/services/remove_status_service.rb
+
15
−
13
View file @
dbd52910
...
...
@@ -4,6 +4,8 @@ class RemoveStatusService < BaseService
include
StreamEntryRenderer
def
call
(
status
)
@payload
=
Oj
.
dump
(
event: :delete
,
payload:
status
.
id
)
remove_from_self
(
status
)
if
status
.
account
.
local?
remove_from_followers
(
status
)
remove_from_mentioned
(
status
)
...
...
@@ -25,25 +27,23 @@ class RemoveStatusService < BaseService
end
def
remove_from_followers
(
status
)
status
.
account
.
followers
.
each
do
|
follower
|
next
unless
follower
.
local?
status
.
account
.
followers
.
where
(
domain:
nil
).
each
do
|
follower
|
unpush
(
:home
,
follower
,
status
)
end
end
def
remove_from_mentioned
(
status
)
return
unless
status
.
local?
notified_domains
=
[]
status
.
mentions
.
each
do
|
mention
|
mentioned_account
=
mention
.
account
if
mentioned_account
.
local?
unpush
(
:mentions
,
mentioned_account
,
status
)
else
next
if
notified_domains
.
include?
(
mentioned_account
.
domain
)
notified_domains
<<
mentioned_account
.
domain
send_delete_salmon
(
mentioned_account
,
status
)
end
next
if
mentioned_account
.
local?
next
if
notified_domains
.
include?
(
mentioned_account
.
domain
)
notified_domains
<<
mentioned_account
.
domain
send_delete_salmon
(
mentioned_account
,
status
)
end
end
...
...
@@ -65,17 +65,19 @@ class RemoveStatusService < BaseService
redis
.
zremrangebyscore
(
FeedManager
.
instance
.
key
(
type
,
receiver
.
id
),
status
.
id
,
status
.
id
)
end
Redis
.
current
.
publish
(
receiver
.
id
,
Oj
.
dump
(
event: :delete
,
payload:
status
.
id
)
)
Redis
.
current
.
publish
(
"timeline:
#{
receiver
.
id
}
"
,
@payload
)
end
def
remove_from_hashtags
(
status
)
status
.
tags
.
each
do
|
tag
|
Redis
.
current
.
publish
(
"hashtag:
#{
tag
.
name
}
"
,
Oj
.
dump
(
event: :delete
,
payload:
status
.
id
))
status
.
tags
.
pluck
(
:name
)
do
|
hashtag
|
Redis
.
current
.
publish
(
"hashtag:
#{
hashtag
}
"
,
@payload
)
Redis
.
current
.
publish
(
"hashtag:
#{
hashtag
}
:local"
,
@payload
)
if
status
.
local?
end
end
def
remove_from_public
(
status
)
Redis
.
current
.
publish
(
'public'
,
Oj
.
dump
(
event: :delete
,
payload:
status
.
id
))
Redis
.
current
.
publish
(
'public'
,
@payload
)
Redis
.
current
.
publish
(
'public:local'
,
@payload
)
if
status
.
local?
end
def
redis
...
...
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