Merge branch 'master' into glitch-soc/merge-upstream

Conflicts:
- `app/serializers/rest/account_serializer.rb`:
  Upstream added code too close to glitch-soc-specific followers-hiding code.
  Ported upstream changes.
This commit is contained in:
Thibaut Girka
2020-01-27 15:46:50 +01:00
38 changed files with 323 additions and 129 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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