diff options
author | rinpatch <rinpatch@sdf.org> | 2019-01-13 13:38:28 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-01-13 13:38:28 +0300 |
commit | e4dc3f71aea900e566c0d66ddffc5cd57e3920dd (patch) | |
tree | d0b0edfd3c7aa4c2015b0b461a4c40895e16eba9 /lib/pleroma/notification.ex | |
parent | 9a6236e69d2709c0df374574fd77c4b2bc3d68fb (diff) | |
parent | 19b6a8239387869c69c6885044ee488d097b723f (diff) | |
download | pleroma-e4dc3f71aea900e566c0d66ddffc5cd57e3920dd.tar.gz |
Resolve merge conflict
Diffstat (limited to 'lib/pleroma/notification.ex')
-rw-r--r-- | lib/pleroma/notification.ex | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 47f6b6ee7..c7d01f63b 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Notification do use Ecto.Schema alias Pleroma.{User, Activity, Notification, Repo, Object} @@ -76,9 +80,8 @@ defmodule Pleroma.Notification do end def clear(user) do - query = from(n in Notification, where: n.user_id == ^user.id) - - Repo.delete_all(query) + from(n in Notification, where: n.user_id == ^user.id) + |> Repo.delete_all() end def dismiss(%{id: user_id} = _user, id) do @@ -106,7 +109,12 @@ 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"]}) or - user.ap_id == activity.data["actor"] do + user.ap_id == activity.data["actor"] or + (activity.data["type"] == "Follow" and + Enum.any?(Notification.for_user(user), fn notif -> + notif.activity.data["type"] == "Follow" and + notif.activity.data["actor"] == activity.data["actor"] + end)) do notification = %Notification{user_id: user.id, activity: activity} {:ok, notification} = Repo.insert(notification) Pleroma.Web.Streamer.stream("user", notification) |