Class: NewsmastMastodon::BanStatusWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/newsmast_mastodon/ban_status_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(status_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/workers/newsmast_mastodon/ban_status_worker.rb', line 11

def perform(status_id)
  status = Status.includes(:account, :tags).find_by(id: status_id)
  return unless status

  is_status_banned = NewsmastMastodon::BanStatusService.new.check_and_ban_status(status)

  if is_status_banned
    attrs = {
      is_banned: is_status_banned,
      updated_at: Time.current
    }
    if status.local?
      attrs.merge!(sensitive: true, spoiler_text: 'Sensitive content!!!')
    end
    status.update!(attrs)
  else
    NewsmastMastodon::ReblogChannelsService.new.call(status) if reblog_enabled?(is_status_banned)
  end
end