1
0

mute_service.rb 542 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class MuteService < BaseService
  3. def call(account, target_account, notifications: nil, duration: 0)
  4. return if account.id == target_account.id
  5. mute = account.mute!(target_account, notifications: notifications, duration: duration)
  6. if mute.hide_notifications?
  7. BlockWorker.perform_async(account.id, target_account.id)
  8. else
  9. MuteWorker.perform_async(account.id, target_account.id)
  10. end
  11. DeleteMuteWorker.perform_at(duration.seconds, mute.id) if duration != 0
  12. mute
  13. end
  14. end