diff options
author | ThibG <thib@sitedethib.com> | 2020-01-27 17:26:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-27 17:26:53 +0100 |
commit | 67b8af34b3df55ba74a53af731f275d0a4c6d9f8 (patch) | |
tree | d1f2420e0ea7cea72ea8032ce005c39c36f38a43 /app/workers | |
parent | 8924743349ec5ce37cd949445e071c14968ec2ec (diff) | |
parent | cf230d551f3081115402f74d4326a2682f27fedc (diff) |
Merge pull request #1271 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/workers')
4 files changed, 19 insertions, 4 deletions
diff --git a/app/workers/publish_announcement_reaction_worker.rb b/app/workers/publish_announcement_reaction_worker.rb index e01deb64d..418dc7127 100644 --- a/app/workers/publish_announcement_reaction_worker.rb +++ b/app/workers/publish_announcement_reaction_worker.rb @@ -13,7 +13,7 @@ class PublishAnnouncementReactionWorker payload = InlineRenderer.render(reaction, nil, :reaction).tap { |h| h[:announcement_id] = announcement_id.to_s } payload = Oj.dump(event: :'announcement.reaction', payload: payload) - Account.joins(:user).where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago).find_each do |account| + FeedManager.instance.with_active_accounts do |account| redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}") end rescue ActiveRecord::RecordNotFound diff --git a/app/workers/publish_scheduled_announcement_worker.rb b/app/workers/publish_scheduled_announcement_worker.rb index 4b2014e34..efca39d3d 100644 --- a/app/workers/publish_scheduled_announcement_worker.rb +++ b/app/workers/publish_scheduled_announcement_worker.rb @@ -6,12 +6,13 @@ class PublishScheduledAnnouncementWorker def perform(announcement_id) announcement = Announcement.find(announcement_id) - announcement.update(published: true) + + announcement.publish! unless announcement.published? payload = InlineRenderer.render(announcement, nil, :announcement) payload = Oj.dump(event: :announcement, payload: payload) - Account.joins(:user).where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago).find_each do |account| + FeedManager.instance.with_active_accounts do |account| redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}") end end diff --git a/app/workers/scheduler/scheduled_statuses_scheduler.rb b/app/workers/scheduler/scheduled_statuses_scheduler.rb index 4262f1d01..9cfe949de 100644 --- a/app/workers/scheduler/scheduled_statuses_scheduler.rb +++ b/app/workers/scheduler/scheduled_statuses_scheduler.rb @@ -34,7 +34,7 @@ class Scheduler::ScheduledStatusesScheduler end def unpublish_expired_announcements! - expired_announcements.in_batches.update_all(published: false) + expired_announcements.in_batches.update_all(published: false, scheduled_at: nil) end def expired_announcements diff --git a/app/workers/unpublish_announcement_worker.rb b/app/workers/unpublish_announcement_worker.rb new file mode 100644 index 000000000..e99d70cf8 --- /dev/null +++ b/app/workers/unpublish_announcement_worker.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class UnpublishAnnouncementWorker + include Sidekiq::Worker + include Redisable + + def perform(announcement_id) + payload = Oj.dump(event: :'announcement.delete', payload: announcement_id.to_s) + + FeedManager.instance.with_active_accounts do |account| + redis.publish("timeline:#{account.id}", payload) if redis.exists("subscribed:timeline:#{account.id}") + end + end +end |