Skip to content

Commit

Permalink
Fix remove group status
Browse files Browse the repository at this point in the history
  • Loading branch information
noellabo committed Aug 19, 2021
1 parent 8fe8907 commit f8fba21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/services/batched_remove_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def unpush_from_list_timelines(account, statuses)
def unpush_from_group_timelines(status)
return unless status.account.group?

payload = Oj.dump(event: :delete, payload: status.reblog.id.to_s)
payload = Oj.dump(event: :delete, payload: status.reblog? ? status.reblog.id.to_s : status.id.to_s)

redis.publish("timeline:group:#{status.account.id}", payload)

Expand Down
19 changes: 10 additions & 9 deletions app/services/remove_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ class RemoveStatusService < BaseService
# @option [Boolean] :immediate
# @option [Boolean] :original_removed
def call(status, **options)
@payload = Oj.dump(event: :delete, payload: status.id.to_s)
@reblog_payload = Oj.dump(event: :delete, payload: status.reblog.id.to_s) if status.reblog
@status = status
@account = status.account
@options = options
@payload = Oj.dump(event: :delete, payload: status.id.to_s)
@status = status
@account = status.account
@options = options

@status.discard

Expand Down Expand Up @@ -123,17 +122,19 @@ def remove_from_hashtags
end

def remove_from_group
redis.publish("timeline:group:#{@status.account.id}", @reblog_payload)
payload = @status.reblog? ? Oj.dump(event: :delete, payload: @status.reblog.id.to_s) : @payload

redis.publish("timeline:group:#{@status.account.id}", payload)

@status.tags.map(&:name).each do |hashtag|
redis.publish("timeline:group:#{@status.account.id}:#{hashtag.mb_chars.downcase}", @reblog_payload)
redis.publish("timeline:group:#{@status.account.id}:#{hashtag.mb_chars.downcase}", payload)
end

if @status.media_attachments.any?
redis.publish("timeline:group:media:#{@status.account.id}", @reblog_payload)
redis.publish("timeline:group:media:#{@status.account.id}", payload)

@status.tags.map(&:name).each do |hashtag|
redis.publish("timeline:group:media:#{@status.account.id}:#{hashtag.mb_chars.downcase}", @reblog_payload)
redis.publish("timeline:group:media:#{@status.account.id}:#{hashtag.mb_chars.downcase}", payload)
end
end
end
Expand Down

0 comments on commit f8fba21

Please sign in to comment.