X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fnotification.ex;h=75d7461e41dcce52120560cd4112a6af135b2e47;hb=934125695d640a08de136ef3924909aaa81fdcc1;hp=e26e49c8cc5d01468f3e47beba2084869c81dc74;hpb=b3d67750f04d7c72c3e1deeb6df573cbb195146a;p=akkoma diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index e26e49c8c..75d7461e4 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -42,6 +42,20 @@ defmodule Pleroma.Notification do Repo.all(query) end + def set_read_up_to(%{id: user_id} = _user, id) do + query = + from( + n in Notification, + where: n.user_id == ^user_id, + where: n.id <= ^id, + update: [ + set: [seen: true] + ] + ) + + Repo.update_all(query, []) + end + def get(%{id: user_id} = _user, id) do query = from( @@ -91,7 +105,8 @@ defmodule Pleroma.Notification do # TODO move to sql, too. def create_notification(%Activity{} = activity, %User{} = user) do - unless User.blocks?(user, %{ap_id: activity.data["actor"]}) do + unless User.blocks?(user, %{ap_id: activity.data["actor"]}) or + user.ap_id == activity.data["actor"] do notification = %Notification{user_id: user.id, activity: activity} {:ok, notification} = Repo.insert(notification) Pleroma.Web.Streamer.stream("user", notification)