mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-14 23:24:55 +01:00
1060666c58
* Add support for editing for published statuses * Fix references to stripped-out code * Various fixes and improvements * Further fixes and improvements * Fix updates being potentially sent to unauthorized recipients * Various fixes and improvements * Fix wrong words in test * Fix notifying accounts that were tagged but were not in the audience * Fix mistake
40 lines
783 B
Ruby
40 lines
783 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PushUpdateWorker
|
|
include Sidekiq::Worker
|
|
include Redisable
|
|
|
|
def perform(account_id, status_id, timeline_id = nil, options = {})
|
|
@account = Account.find(account_id)
|
|
@status = Status.find(status_id)
|
|
@timeline_id = timeline_id || "timeline:#{account.id}"
|
|
@options = options.symbolize_keys
|
|
|
|
publish!
|
|
rescue ActiveRecord::RecordNotFound
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def payload
|
|
InlineRenderer.render(@status, @account, :status)
|
|
end
|
|
|
|
def message
|
|
Oj.dump(
|
|
event: update? ? :'status.update' : :update,
|
|
payload: payload,
|
|
queued_at: (Time.now.to_f * 1000.0).to_i
|
|
)
|
|
end
|
|
|
|
def publish!
|
|
redis.publish(@timeline_id, message)
|
|
end
|
|
|
|
def update?
|
|
@options[:update]
|
|
end
|
|
end
|