[#1335] Implemented notification mutes and reblog mutes as UserRelationships. User to UserRelationship relations and functions refactoring.

This commit is contained in:
Ivan Tashkinov 2019-11-19 23:22:10 +03:00
commit ba5cc30165
21 changed files with 203 additions and 229 deletions

View file

@ -93,7 +93,7 @@ defmodule Pleroma.NotificationTest do
activity = insert(:note_activity)
author = User.get_cached_by_ap_id(activity.data["actor"])
user = insert(:user)
{:ok, _user_block} = User.block(user, author)
{:ok, _user_relationship} = User.block(user, author)
assert Notification.create_notification(activity, user)
end
@ -112,7 +112,7 @@ defmodule Pleroma.NotificationTest do
muter = insert(:user)
muted = insert(:user)
{:ok, _user_mute} = User.mute(muter, muted, false)
{:ok, _user_relationships} = User.mute(muter, muted, false)
{:ok, activity} = CommonAPI.post(muted, %{"status" => "Hi @#{muter.nickname}"})
@ -636,7 +636,7 @@ defmodule Pleroma.NotificationTest do
test "it returns notifications for muted user without notifications" do
user = insert(:user)
muted = insert(:user)
{:ok, _user_mute} = User.mute(user, muted, false)
{:ok, _user_relationships} = User.mute(user, muted, false)
{:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
@ -646,10 +646,7 @@ defmodule Pleroma.NotificationTest do
test "it doesn't return notifications for muted user with notifications" do
user = insert(:user)
muted = insert(:user)
{:ok, _user_mute} = User.mute(user, muted)
# Refreshing to reflect embedded ap id relation fields (remove once removed)
user = refresh_record(user)
{:ok, _user_relationships} = User.mute(user, muted)
{:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
@ -659,7 +656,7 @@ defmodule Pleroma.NotificationTest do
test "it doesn't return notifications for blocked user" do
user = insert(:user)
blocked = insert(:user)
{:ok, _user_block} = User.block(user, blocked)
{:ok, _user_relationship} = User.block(user, blocked)
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})
@ -689,7 +686,7 @@ defmodule Pleroma.NotificationTest do
test "it returns notifications from a muted user when with_muted is set" do
user = insert(:user)
muted = insert(:user)
{:ok, _user_mute} = User.mute(user, muted)
{:ok, _user_relationships} = User.mute(user, muted)
{:ok, _activity} = CommonAPI.post(muted, %{"status" => "hey @#{user.nickname}"})
@ -699,7 +696,7 @@ defmodule Pleroma.NotificationTest do
test "it doesn't return notifications from a blocked user when with_muted is set" do
user = insert(:user)
blocked = insert(:user)
{:ok, _user_block} = User.block(user, blocked)
{:ok, _user_relationship} = User.block(user, blocked)
{:ok, _activity} = CommonAPI.post(blocked, %{"status" => "hey @#{user.nickname}"})