闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
641 B

  1. # frozen_string_literal: true
  2. class UnfavouriteService < BaseService
  3. include Payloadable
  4. def call(account, status)
  5. favourite = Favourite.find_by!(account: account, status: status)
  6. favourite.destroy!
  7. create_notification(favourite) if !status.account.local? && status.account.activitypub?
  8. favourite
  9. end
  10. private
  11. def create_notification(favourite)
  12. status = favourite.status
  13. ActivityPub::DeliveryWorker.perform_async(build_json(favourite), favourite.account_id, status.account.inbox_url)
  14. end
  15. def build_json(favourite)
  16. Oj.dump(serialize_payload(favourite, ActivityPub::UndoLikeSerializer))
  17. end
  18. end