glitch-soc/app/services/mute_service.rb
David Yip 5e6a09498a
Add notes to blocks (#193)
In this commit, we also push note creation into the AccountInteractions
concern, where we can:

1. create and persist model objects inside transactions without having
   to include job queuing inside the transaction
2. commonize the don't-add-a-blank-note check

Finally, this commit resolves a invocation-on-nil in
REST::RelationshipSerializer.
2018-01-26 04:05:42 -06:00

14 lines
392 B
Ruby

# frozen_string_literal: true
class MuteService < BaseService
def call(account, target_account, notifications: nil, note: nil)
return if account.id == target_account.id
ActiveRecord::Base.transaction do
mute = account.mute!(target_account, notifications: notifications, note: note)
BlockWorker.perform_async(account.id, target_account.id)
mute
end
end
end