diff options
author | lain <lain@soykaf.club> | 2018-02-17 20:13:12 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-02-17 20:13:12 +0100 |
commit | e1b12a778211378534fa176bbc4456c3a100b23f (patch) | |
tree | 15943903162308076f21175b927bdd893e2f1c26 /lib | |
parent | 1f98de20793b60fa16a10f4bb21dc017a96ae122 (diff) | |
download | pleroma-e1b12a778211378534fa176bbc4456c3a100b23f.tar.gz pleroma-e1b12a778211378534fa176bbc4456c3a100b23f.zip |
ActivityPub: Handle incoming likes.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 6cf7cfe35..82fcf0898 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -3,6 +3,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do A module to handle coding from internal to wire ActivityPub and back. """ alias Pleroma.User + alias Pleroma.Object alias Pleroma.Web.ActivityPub.ActivityPub @doc """ @@ -62,6 +63,20 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do end end + def handle_incoming(%{"type" => "Like", "object" => object_id, "actor" => actor, "id" => id} = data) do + with %User{} = actor <- User.get_or_fetch_by_ap_id(actor), + %Object{} = object <- Object.get_by_ap_id(object_id), + {:ok, activity, object} <- ActivityPub.like(actor, object, id, false) do + {:ok, activity} + else + _e -> :error + end + end + + # TODO + # Accept + # Undo + def handle_incoming(_), do: :error @doc |