2016-11-16 00:56:29 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-27 06:55:21 +09:00
|
|
|
class UnfavouriteService < BaseService
|
|
|
|
def call(account, status)
|
|
|
|
favourite = Favourite.find_by!(account: account, status: status)
|
|
|
|
favourite.destroy!
|
|
|
|
|
2017-02-12 08:48:53 +09:00
|
|
|
NotificationWorker.perform_async(build_xml(favourite), account.id, status.account_id) unless status.local?
|
2016-09-27 06:55:21 +09:00
|
|
|
|
|
|
|
favourite
|
|
|
|
end
|
2017-02-12 08:48:53 +09:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def build_xml(favourite)
|
2017-07-19 08:37:26 +09:00
|
|
|
OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfavourite_salmon(favourite))
|
2017-02-12 08:48:53 +09:00
|
|
|
end
|
2016-09-27 06:55:21 +09:00
|
|
|
end
|