about summary refs log tree commit diff
path: root/app/services/mute_service.rb
blob: 9ae9afd623498d3a6b0baaa7d6cb7d91a88fea6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class MuteService < BaseService
  def call(account, target_account, notifications: nil, duration: 0)
    return if account.id == target_account.id

    mute = account.mute!(target_account, notifications: notifications, duration: duration)

    if mute.hide_notifications?
      BlockWorker.perform_async(account.id, target_account.id)
    else
      MuteWorker.perform_async(account.id, target_account.id)
    end

    DeleteMuteWorker.perform_at(duration.seconds, mute.id) if duration != 0

    mute
  end
end