aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-09-11 20:41:05 +0200
committerRoger Braun <roger@rogerbraun.net>2017-09-11 20:41:05 +0200
commitbcce3e5dd2c9ba262d73d398f3e8a14eee21f009 (patch)
tree7183a804525a72a0c297075b60fe9d8e08779905 /lib
parent61adf676d56db274cb4688a137787e8806e77be9 (diff)
downloadpleroma-bcce3e5dd2c9ba262d73d398f3e8a14eee21f009.tar.gz
Add favorites to notifications.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex6
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index f8835fce6..031f71091 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -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)
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 07272e5b3..3804a39f0 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -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)