aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/notification.ex
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2019-06-29 00:52:50 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2019-06-29 00:52:50 +0300
commit657277ffc0d3d25be4376ed629057a2d2cefb2e1 (patch)
tree3fdd4ca236669df9b2afc5bfcd0e5d6002e23666 /lib/pleroma/notification.ex
parentc0fa0001476a8a45878a0c75125627164497eddf (diff)
parentc6668c2e7b9908e479527914ca7eb2c838aaab06 (diff)
downloadpleroma-657277ffc0d3d25be4376ed629057a2d2cefb2e1.tar.gz
Resolve conflicts
Diffstat (limited to 'lib/pleroma/notification.ex')
-rw-r--r--lib/pleroma/notification.ex17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 736ebc3af..118560d34 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -13,6 +13,8 @@ defmodule Pleroma.Notification do
alias Pleroma.User
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.CommonAPI.Utils
+ alias Pleroma.Web.Push
+ alias Pleroma.Web.Streamer
import Ecto.Query
import Ecto.Changeset
@@ -149,8 +151,7 @@ defmodule Pleroma.Notification do
end
end
- def create_notifications(%Activity{data: %{"to" => _, "type" => type}} = activity)
- when type in ["Create", "Like", "Announce", "Follow"] do
+ def create_notifications(%Activity{data: %{"to" => _, "type" => "Create"}} = activity) do
object = Object.normalize(activity)
unless object && object.data["type"] == "Answer" do
@@ -162,6 +163,13 @@ defmodule Pleroma.Notification do
end
end
+ def create_notifications(%Activity{data: %{"to" => _, "type" => type}} = activity)
+ when type in ["Like", "Announce", "Follow"] do
+ users = get_notified_from_activity(activity)
+ notifications = Enum.map(users, fn user -> create_notification(activity, user) end)
+ {:ok, notifications}
+ end
+
def create_notifications(_), do: {:ok, []}
# TODO move to sql, too.
@@ -169,8 +177,9 @@ defmodule Pleroma.Notification do
unless skip?(activity, user) do
notification = %Notification{user_id: user.id, activity: activity}
{:ok, notification} = Repo.insert(notification)
- Pleroma.Web.Streamer.stream("user", notification)
- Pleroma.Web.Push.send(notification)
+ Streamer.stream("user", notification)
+ Streamer.stream("user:notification", notification)
+ Push.send(notification)
notification
end
end