# 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)
assert nil == Notification.create_notification(activity, user)
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
describe "get notification" do
end
test "with credentials", %{conn: conn, user: current_user} do
+ other_user = insert(:user)
+
{:ok, activity} =
- ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: current_user})
+ ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: other_user})
conn =
conn