Add favorites to notifications.
authorRoger Braun <roger@rogerbraun.net>
Mon, 11 Sep 2017 18:41:05 +0000 (20:41 +0200)
committerRoger Braun <roger@rogerbraun.net>
Mon, 11 Sep 2017 18:41:05 +0000 (20:41 +0200)
lib/pleroma/notification.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index f8835fce6fae955b683a74001fa89d27d6946d8c..031f71091e1f156e48e6ab8e18e84c440666a71e 100644 (file)
@@ -20,7 +20,7 @@ defmodule Pleroma.Notification do
     Repo.all(query)
   end
 
-  def create_notifications(%Activity{id: id, data: %{"to" => to, "type" => type}} = activity) when type in ["Create"] do
+  def create_notifications(%Activity{id: id, data: %{"to" => to, "type" => type}} = activity) when type in ["Create", "Like"] do
     users = User.get_notified_from_activity(activity)
 
     notifications = Enum.map(users, fn (user) -> create_notification(activity, user) end)
index 07272e5b36aab8e163ce439567c77ce350445990..3804a39f00fa4def33ce5738b3122bc7fa8c64b0 100644 (file)
@@ -137,7 +137,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     result = Enum.map(notifications, fn (%{id: id, activity: activity, inserted_at: created_at}) ->
       actor = User.get_cached_by_ap_id(activity.data["actor"])
       case activity.data["type"] do
-        "Create" -> %{ id: id, type: "mention", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), status: StatusView.render("status.json", %{activity: activity})}
+        "Create" ->
+          %{id: id, type: "mention", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), status: StatusView.render("status.json", %{activity: activity})}
+        "Like" ->
+          liked_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"])
+          %{id: id, type: "favourite", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), status: StatusView.render("status.json", %{activity: liked_activity})}
         _ -> nil
       end
     end)