Merge branch 'remake-remodel' into develop
[akkoma] / lib / pleroma / web / activity_pub / side_effects.ex
1 defmodule Pleroma.Web.ActivityPub.SideEffects do
2 @moduledoc """
3 This module looks at an inserted object and executes the side effects that it
4 implies. For example, a `Like` activity will increase the like count on the
5 liked object, a `Follow` activity will add the user to the follower
6 collection, and so on.
7 """
8 alias Pleroma.Notification
9 alias Pleroma.Object
10 alias Pleroma.Web.ActivityPub.Utils
11
12 def handle(object, meta \\ [])
13
14 # Tasks this handles:
15 # - Add like to object
16 # - Set up notification
17 def handle(%{data: %{"type" => "Like"}} = object, meta) do
18 liked_object = Object.get_by_ap_id(object.data["object"])
19 Utils.add_like_to_object(object, liked_object)
20 Notification.create_notifications(object)
21 {:ok, object, meta}
22 end
23
24 # Nothing to do
25 def handle(object, meta) do
26 {:ok, object, meta}
27 end
28 end