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

class UnfavouriteService < BaseService
  include StreamEntryRenderer

  def call(account, status)
    favourite = Favourite.find_by!(account: account, status: status)
    favourite.destroy!

    unless status.local?
      NotificationWorker.perform_async(stream_entry_to_xml(favourite.stream_entry), account.id, status.account_id)
    end

    favourite
  end
end