Merge branch 'no-self-notification' into 'develop'
Do not create notification for yourself Closes #121 See merge request pleroma/pleroma!148
This commit is contained in:
commit
2d83efa5de
3 changed files with 12 additions and 2 deletions
|
@ -91,7 +91,8 @@ defmodule Pleroma.Notification do
|
||||||
|
|
||||||
# TODO move to sql, too.
|
# TODO move to sql, too.
|
||||||
def create_notification(%Activity{} = activity, %User{} = user) do
|
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}
|
notification = %Notification{user_id: user.id, activity: activity}
|
||||||
{:ok, notification} = Repo.insert(notification)
|
{:ok, notification} = Repo.insert(notification)
|
||||||
Pleroma.Web.Streamer.stream("user", notification)
|
Pleroma.Web.Streamer.stream("user", notification)
|
||||||
|
|
|
@ -33,6 +33,13 @@ defmodule Pleroma.NotificationTest do
|
||||||
|
|
||||||
assert nil == Notification.create_notification(activity, user)
|
assert nil == Notification.create_notification(activity, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it doesn't create a notification for user if he is the activity author" do
|
||||||
|
activity = insert(:note_activity)
|
||||||
|
author = User.get_by_ap_id(activity.data["actor"])
|
||||||
|
|
||||||
|
assert nil == Notification.create_notification(activity, author)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "get notification" do
|
describe "get notification" do
|
||||||
|
|
|
@ -257,8 +257,10 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with credentials", %{conn: conn, user: current_user} do
|
test "with credentials", %{conn: conn, user: current_user} do
|
||||||
|
other_user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: current_user})
|
ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: other_user})
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in a new issue