about summary refs log tree commit diff
path: root/app/services/mute_service.rb
blob: 5e7e1d292b918a04a22f79d62702c8a0e1435a04 (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, timelines_only: nil, duration: 0)
    return if account.id == target_account.id

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

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

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

    mute
  end
end