about summary refs log blame commit diff
path: root/app/services/mute_service.rb
blob: 9ae9afd623498d3a6b0baaa7d6cb7d91a88fea6f (plain) (tree)
1
2
3
4
5
6
7
8

                               
                                                                    
                                             
 
                                                                                          
 

                                                              
                                                             
       
 
                                                                           
        
     
   
# 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