The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

20 lines
643 B

  1. # frozen_string_literal: true
  2. class PublishScheduledAnnouncementWorker
  3. include Sidekiq::Worker
  4. include Redisable
  5. def perform(announcement_id)
  6. announcement = Announcement.find(announcement_id)
  7. announcement.update(published: true, published_at: Time.now.utc, scheduled_at: nil) unless announcement.published?
  8. payload = InlineRenderer.render(announcement, nil, :announcement)
  9. payload = Oj.dump(event: :announcement, payload: payload)
  10. FeedManager.instance.with_active_accounts do |account|
  11. redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}")
  12. end
  13. end
  14. end