Merge branch 'develop' into issue/1276
This commit is contained in:
commit
6fbafb1cdc
55 changed files with 1159 additions and 417 deletions
|
|
@ -298,7 +298,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert json_response(conn1, :ok)
|
||||
assert Enum.any?(conn1.resp_headers, &(&1 == {"x-cache", "MISS from Pleroma"}))
|
||||
|
||||
Activity.delete_by_ap_id(activity.object.data["id"])
|
||||
Activity.delete_all_by_object_ap_id(activity.object.data["id"])
|
||||
|
||||
conn2 =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity_five = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, user} = User.block(user, %{ap_id: activity_five.data["actor"]})
|
||||
{:ok, _user_relationship} = User.block(user, %{ap_id: activity_five.data["actor"]})
|
||||
|
||||
activities = ActivityPub.fetch_activities_for_context("2hu", %{"blocking_user" => user})
|
||||
assert activities == [activity_two, activity]
|
||||
|
|
@ -500,7 +500,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity_three = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
booster = insert(:user)
|
||||
{:ok, user} = User.block(user, %{ap_id: activity_one.data["actor"]})
|
||||
{:ok, _user_relationship} = User.block(user, %{ap_id: activity_one.data["actor"]})
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{"blocking_user" => user, "skip_preload" => true})
|
||||
|
|
@ -509,7 +509,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert Enum.member?(activities, activity_three)
|
||||
refute Enum.member?(activities, activity_one)
|
||||
|
||||
{:ok, user} = User.unblock(user, %{ap_id: activity_one.data["actor"]})
|
||||
{:ok, _user_block} = User.unblock(user, %{ap_id: activity_one.data["actor"]})
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{"blocking_user" => user, "skip_preload" => true})
|
||||
|
|
@ -518,7 +518,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert Enum.member?(activities, activity_three)
|
||||
assert Enum.member?(activities, activity_one)
|
||||
|
||||
{:ok, user} = User.block(user, %{ap_id: activity_three.data["actor"]})
|
||||
{:ok, _user_relationship} = User.block(user, %{ap_id: activity_three.data["actor"]})
|
||||
{:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(activity_three.id, booster)
|
||||
%Activity{} = boost_activity = Activity.get_create_by_object_ap_id(id)
|
||||
activity_three = Activity.get_by_id(activity_three.id)
|
||||
|
|
@ -545,7 +545,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
blockee = insert(:user)
|
||||
friend = insert(:user)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blockee)
|
||||
{:ok, _user_relationship} = User.block(blocker, blockee)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey!"})
|
||||
|
||||
|
|
@ -568,7 +568,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
blockee = insert(:user)
|
||||
friend = insert(:user)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blockee)
|
||||
{:ok, _user_relationship} = User.block(blocker, blockee)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey!"})
|
||||
|
||||
|
|
@ -614,7 +614,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity_three = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
booster = insert(:user)
|
||||
{:ok, user} = User.mute(user, %User{ap_id: activity_one.data["actor"]})
|
||||
|
||||
activity_one_actor = User.get_by_ap_id(activity_one.data["actor"])
|
||||
{:ok, _user_relationships} = User.mute(user, activity_one_actor)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{"muting_user" => user, "skip_preload" => true})
|
||||
|
|
@ -635,7 +637,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert Enum.member?(activities, activity_three)
|
||||
assert Enum.member?(activities, activity_one)
|
||||
|
||||
{:ok, user} = User.unmute(user, %User{ap_id: activity_one.data["actor"]})
|
||||
{:ok, _user_mute} = User.unmute(user, activity_one_actor)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{"muting_user" => user, "skip_preload" => true})
|
||||
|
|
@ -644,7 +646,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert Enum.member?(activities, activity_three)
|
||||
assert Enum.member?(activities, activity_one)
|
||||
|
||||
{:ok, user} = User.mute(user, %User{ap_id: activity_three.data["actor"]})
|
||||
activity_three_actor = User.get_by_ap_id(activity_three.data["actor"])
|
||||
{:ok, _user_relationships} = User.mute(user, activity_three_actor)
|
||||
{:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(activity_three.id, booster)
|
||||
%Activity{} = boost_activity = Activity.get_create_by_object_ap_id(id)
|
||||
activity_three = Activity.get_by_id(activity_three.id)
|
||||
|
|
@ -791,7 +794,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
booster = insert(:user)
|
||||
{:ok, user} = CommonAPI.hide_reblogs(user, booster)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, booster)
|
||||
|
||||
{:ok, activity, _} = CommonAPI.repeat(activity.id, booster)
|
||||
|
||||
|
|
@ -804,8 +807,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
booster = insert(:user)
|
||||
{:ok, user} = CommonAPI.hide_reblogs(user, booster)
|
||||
{:ok, user} = CommonAPI.show_reblogs(user, booster)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, booster)
|
||||
{:ok, _reblog_mute} = CommonAPI.show_reblogs(user, booster)
|
||||
|
||||
{:ok, activity, _} = CommonAPI.repeat(activity.id, booster)
|
||||
|
||||
|
|
@ -1256,6 +1259,21 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
|
||||
assert object.data["repliesCount"] == 0
|
||||
end
|
||||
|
||||
test "it passes delete activity through MRF before deleting the object" do
|
||||
rewrite_policy = Pleroma.Config.get([:instance, :rewrite_policy])
|
||||
Pleroma.Config.put([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.DropPolicy)
|
||||
|
||||
on_exit(fn -> Pleroma.Config.put([:instance, :rewrite_policy], rewrite_policy) end)
|
||||
|
||||
note = insert(:note_activity)
|
||||
object = Object.normalize(note)
|
||||
|
||||
{:error, {:reject, _}} = ActivityPub.delete(object)
|
||||
|
||||
assert Activity.get_by_id(note.id)
|
||||
assert Repo.get(Object, object.id).data["type"] == object.data["type"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "timeline post-processing" do
|
||||
|
|
@ -1619,10 +1637,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
activity = %Activity{activity | object: nil}
|
||||
|
||||
assert [%Notification{activity: ^activity}] =
|
||||
Notification.for_user_since(follower, ~N[2019-04-13 11:22:33])
|
||||
Notification.for_user(follower, %{with_move: true})
|
||||
|
||||
assert [%Notification{activity: ^activity}] =
|
||||
Notification.for_user_since(follower_move_opted_out, ~N[2019-04-13 11:22:33])
|
||||
Notification.for_user(follower_move_opted_out, %{with_move: true})
|
||||
end
|
||||
|
||||
test "old user must be in the new user's `also_known_as` list" do
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
|||
user = insert(:user)
|
||||
{:ok, target} = User.get_or_fetch("http://mastodon.example.org/users/admin")
|
||||
|
||||
{:ok, user} = User.block(user, target)
|
||||
{:ok, _user_relationship} = User.block(user, target)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|
|
|
|||
|
|
@ -636,47 +636,4 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
assert updated_object.data["announcement_count"] == 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "get_reports_grouped_by_status/1" do
|
||||
setup do
|
||||
[reporter, target_user] = insert_pair(:user)
|
||||
first_status = insert(:note_activity, user: target_user)
|
||||
second_status = insert(:note_activity, user: target_user)
|
||||
|
||||
CommonAPI.report(reporter, %{
|
||||
"account_id" => target_user.id,
|
||||
"comment" => "I feel offended",
|
||||
"status_ids" => [first_status.id]
|
||||
})
|
||||
|
||||
CommonAPI.report(reporter, %{
|
||||
"account_id" => target_user.id,
|
||||
"comment" => "I feel offended2",
|
||||
"status_ids" => [second_status.id]
|
||||
})
|
||||
|
||||
data = [%{activity: first_status.data["id"]}, %{activity: second_status.data["id"]}]
|
||||
|
||||
{:ok,
|
||||
%{
|
||||
first_status: first_status,
|
||||
second_status: second_status,
|
||||
data: data
|
||||
}}
|
||||
end
|
||||
|
||||
test "works for deprecated reports format", %{
|
||||
first_status: first_status,
|
||||
second_status: second_status,
|
||||
data: data
|
||||
} do
|
||||
groups = Utils.get_reports_grouped_by_status(data).groups
|
||||
|
||||
first_group = Enum.find(groups, &(&1.status.id == first_status.data["id"]))
|
||||
second_group = Enum.find(groups, &(&1.status.id == second_status.data["id"]))
|
||||
|
||||
assert first_group.status.id == first_status.data["id"]
|
||||
assert second_group.status.id == second_status.data["id"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
alias Pleroma.UserInviteToken
|
||||
alias Pleroma.Web.ActivityPub.Relay
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.MastodonAPI.StatusView
|
||||
alias Pleroma.Web.MediaProxy
|
||||
import Pleroma.Factory
|
||||
|
||||
|
|
@ -1612,6 +1613,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
first_status: Activity.get_by_ap_id_with_object(first_status.data["id"]),
|
||||
second_status: Activity.get_by_ap_id_with_object(second_status.data["id"]),
|
||||
third_status: Activity.get_by_ap_id_with_object(third_status.data["id"]),
|
||||
first_report: first_report,
|
||||
first_status_reports: [first_report, second_report, third_report],
|
||||
second_status_reports: [first_report, second_report],
|
||||
third_status_reports: [first_report],
|
||||
|
|
@ -1638,14 +1640,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
assert length(response["reports"]) == 3
|
||||
|
||||
first_group =
|
||||
Enum.find(response["reports"], &(&1["status"]["id"] == first_status.data["id"]))
|
||||
first_group = Enum.find(response["reports"], &(&1["status"]["id"] == first_status.id))
|
||||
|
||||
second_group =
|
||||
Enum.find(response["reports"], &(&1["status"]["id"] == second_status.data["id"]))
|
||||
second_group = Enum.find(response["reports"], &(&1["status"]["id"] == second_status.id))
|
||||
|
||||
third_group =
|
||||
Enum.find(response["reports"], &(&1["status"]["id"] == third_status.data["id"]))
|
||||
third_group = Enum.find(response["reports"], &(&1["status"]["id"] == third_status.id))
|
||||
|
||||
assert length(first_group["reports"]) == 3
|
||||
assert length(second_group["reports"]) == 2
|
||||
|
|
@ -1656,13 +1655,14 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert first_group["status"] == %{
|
||||
"id" => first_status.data["id"],
|
||||
"content" => first_status.object.data["content"],
|
||||
"published" => first_status.object.data["published"]
|
||||
}
|
||||
assert first_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: first_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
|
||||
assert first_group["account"]["id"] == target_user.id
|
||||
assert(first_group["account"]["id"] == target_user.id)
|
||||
|
||||
assert length(first_group["actors"]) == 1
|
||||
assert hd(first_group["actors"])["id"] == reporter.id
|
||||
|
|
@ -1675,11 +1675,12 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert second_group["status"] == %{
|
||||
"id" => second_status.data["id"],
|
||||
"content" => second_status.object.data["content"],
|
||||
"published" => second_status.object.data["published"]
|
||||
}
|
||||
assert second_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: second_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
|
||||
assert second_group["account"]["id"] == target_user.id
|
||||
|
||||
|
|
@ -1694,11 +1695,12 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert third_group["status"] == %{
|
||||
"id" => third_status.data["id"],
|
||||
"content" => third_status.object.data["content"],
|
||||
"published" => third_status.object.data["published"]
|
||||
}
|
||||
assert third_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: third_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
|
||||
assert third_group["account"]["id"] == target_user.id
|
||||
|
||||
|
|
@ -1708,6 +1710,70 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
assert Enum.map(third_group["reports"], & &1["id"]) --
|
||||
Enum.map(third_status_reports, & &1.id) == []
|
||||
end
|
||||
|
||||
test "reopened report renders status data", %{
|
||||
conn: conn,
|
||||
first_report: first_report,
|
||||
first_status: first_status
|
||||
} do
|
||||
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
first_group = Enum.find(response["reports"], &(&1["status"]["id"] == first_status.id))
|
||||
|
||||
assert first_group["status"] ==
|
||||
Map.put(
|
||||
stringify_keys(StatusView.render("show.json", %{activity: first_status})),
|
||||
"deleted",
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
test "reopened report does not render status data if status has been deleted", %{
|
||||
conn: conn,
|
||||
first_report: first_report,
|
||||
first_status: first_status,
|
||||
target_user: target_user
|
||||
} do
|
||||
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||
{:ok, _} = CommonAPI.delete(first_status.id, target_user)
|
||||
|
||||
refute Activity.get_by_ap_id(first_status.id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["status"][
|
||||
"deleted"
|
||||
] == true
|
||||
|
||||
assert length(Enum.filter(response["reports"], &(&1["status"]["deleted"] == false))) == 2
|
||||
end
|
||||
|
||||
test "account not empty if status was deleted", %{
|
||||
conn: conn,
|
||||
first_report: first_report,
|
||||
first_status: first_status,
|
||||
target_user: target_user
|
||||
} do
|
||||
{:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
|
||||
{:ok, _} = CommonAPI.delete(first_status.id, target_user)
|
||||
|
||||
refute Activity.get_by_ap_id(first_status.id)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/grouped_reports")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["account"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/reports/:id/respond" do
|
||||
|
|
|
|||
37
test/web/chat_channel_test.exs
Normal file
37
test/web/chat_channel_test.exs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
defmodule Pleroma.Web.ChatChannelTest do
|
||||
use Pleroma.Web.ChannelCase
|
||||
alias Pleroma.Web.ChatChannel
|
||||
alias Pleroma.Web.UserSocket
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, _, socket} =
|
||||
socket(UserSocket, "", %{user_name: user.nickname})
|
||||
|> subscribe_and_join(ChatChannel, "chat:public")
|
||||
|
||||
{:ok, socket: socket}
|
||||
end
|
||||
|
||||
test "it broadcasts a message", %{socket: socket} do
|
||||
push(socket, "new_msg", %{"text" => "why is tenshi eating a corndog so cute?"})
|
||||
assert_broadcast("new_msg", %{text: "why is tenshi eating a corndog so cute?"})
|
||||
end
|
||||
|
||||
describe "message lengths" do
|
||||
clear_config([:instance, :chat_limit])
|
||||
|
||||
test "it ignores messages of length zero", %{socket: socket} do
|
||||
push(socket, "new_msg", %{"text" => ""})
|
||||
refute_broadcast("new_msg", %{text: ""})
|
||||
end
|
||||
|
||||
test "it ignores messages above a certain length", %{socket: socket} do
|
||||
Pleroma.Config.put([:instance, :chat_limit], 2)
|
||||
push(socket, "new_msg", %{"text" => "123"})
|
||||
refute_broadcast("new_msg", %{text: "123"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -509,14 +509,14 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
end
|
||||
|
||||
test "add a reblog mute", %{muter: muter, muted: muted} do
|
||||
{:ok, muter} = CommonAPI.hide_reblogs(muter, muted)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
|
||||
|
||||
assert User.showing_reblogs?(muter, muted) == false
|
||||
end
|
||||
|
||||
test "remove a reblog mute", %{muter: muter, muted: muted} do
|
||||
{:ok, muter} = CommonAPI.hide_reblogs(muter, muted)
|
||||
{:ok, muter} = CommonAPI.show_reblogs(muter, muted)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
|
||||
{:ok, _reblog_mute} = CommonAPI.show_reblogs(muter, muted)
|
||||
|
||||
assert User.showing_reblogs?(muter, muted) == true
|
||||
end
|
||||
|
|
@ -526,7 +526,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
test "also unsubscribes a user" do
|
||||
[follower, followed] = insert_pair(:user)
|
||||
{:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
|
||||
{:ok, followed} = User.subscribe(follower, followed)
|
||||
{:ok, _subscription} = User.subscribe(follower, followed)
|
||||
|
||||
assert User.subscribed_to?(follower, followed)
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,50 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
describe "user timelines" do
|
||||
test "respects blocks", %{conn: conn} do
|
||||
user_one = insert(:user)
|
||||
user_two = insert(:user)
|
||||
user_three = insert(:user)
|
||||
|
||||
User.block(user_one, user_two)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user_two, %{"status" => "User one sux0rz"})
|
||||
{:ok, repeat, _} = CommonAPI.repeat(activity.id, user_three)
|
||||
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{user_two.id}/statuses")
|
||||
|
||||
assert [%{"id" => id}] = json_response(resp, 200)
|
||||
assert id == activity.id
|
||||
|
||||
# Even a blocked user will deliver the full user timeline, there would be
|
||||
# no point in looking at a blocked users timeline otherwise
|
||||
resp =
|
||||
conn
|
||||
|> assign(:user, user_one)
|
||||
|> get("/api/v1/accounts/#{user_two.id}/statuses")
|
||||
|
||||
assert [%{"id" => id}] = json_response(resp, 200)
|
||||
assert id == activity.id
|
||||
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{user_three.id}/statuses")
|
||||
|
||||
assert [%{"id" => id}] = json_response(resp, 200)
|
||||
assert id == repeat.id
|
||||
|
||||
# When viewing a third user's timeline, the blocked users will NOT be
|
||||
# shown.
|
||||
resp =
|
||||
conn
|
||||
|> assign(:user, user_one)
|
||||
|> get("/api/v1/accounts/#{user_three.id}/statuses")
|
||||
|
||||
assert [] = json_response(resp, 200)
|
||||
end
|
||||
|
||||
test "gets a users statuses", %{conn: conn} do
|
||||
user_one = insert(:user)
|
||||
user_two = insert(:user)
|
||||
|
|
@ -891,7 +935,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, user} = User.mute(user, other_user)
|
||||
{:ok, _user_relationships} = User.mute(user, other_user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -906,7 +950,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, user} = User.block(user, other_user)
|
||||
{:ok, _user_relationship} = User.block(user, other_user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
assert length(json_response(conn, 200)) == 1
|
||||
|
||||
{:ok, user} = User.mute(user, user2)
|
||||
{:ok, _user_relationships} = User.mute(user, user2)
|
||||
|
||||
conn = assign(build_conn(), :user, user)
|
||||
conn = get(conn, "/api/v1/notifications")
|
||||
|
|
@ -310,7 +310,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
assert length(json_response(conn, 200)) == 1
|
||||
|
||||
{:ok, user} = User.mute(user, user2, false)
|
||||
{:ok, _user_relationships} = User.mute(user, user2, false)
|
||||
|
||||
conn = assign(build_conn(), :user, user)
|
||||
conn = get(conn, "/api/v1/notifications")
|
||||
|
|
@ -333,7 +333,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
assert length(json_response(conn, 200)) == 1
|
||||
|
||||
{:ok, user} = User.mute(user, user2)
|
||||
{:ok, _user_relationships} = User.mute(user, user2)
|
||||
|
||||
conn = assign(build_conn(), :user, user)
|
||||
conn = get(conn, "/api/v1/notifications", %{"with_muted" => "true"})
|
||||
|
|
@ -341,6 +341,32 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
assert length(json_response(conn, 200)) == 1
|
||||
end
|
||||
|
||||
test "see move notifications with `with_move` parameter", %{
|
||||
conn: conn
|
||||
} do
|
||||
old_user = insert(:user)
|
||||
new_user = insert(:user, also_known_as: [old_user.ap_id])
|
||||
follower = insert(:user)
|
||||
|
||||
User.follow(follower, old_user)
|
||||
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
|
||||
Pleroma.Tests.ObanHelpers.perform_all()
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, follower)
|
||||
|> get("/api/v1/notifications")
|
||||
|
||||
assert json_response(conn, 200) == []
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, follower)
|
||||
|> get("/api/v1/notifications", %{"with_move" => "true"})
|
||||
|
||||
assert length(json_response(conn, 200)) == 1
|
||||
end
|
||||
|
||||
defp get_notification_id_by_activity(%{id: id}) do
|
||||
Notification
|
||||
|> Repo.get_by(activity_id: id)
|
||||
|
|
|
|||
|
|
@ -1108,7 +1108,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
activity: activity
|
||||
} do
|
||||
other_user = insert(:user)
|
||||
{:ok, user} = User.block(user, other_user)
|
||||
{:ok, _user_relationship} = User.block(user, other_user)
|
||||
|
||||
{:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
|
||||
|
||||
|
|
@ -1205,7 +1205,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
activity: activity
|
||||
} do
|
||||
other_user = insert(:user)
|
||||
{:ok, user} = User.block(user, other_user)
|
||||
{:ok, _user_relationship} = User.block(user, other_user)
|
||||
|
||||
{:ok, _, _} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
blocker = insert(:user)
|
||||
blocked = insert(:user)
|
||||
user = insert(:user)
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
{:ok, _user_relationship} = User.block(blocker, blocked)
|
||||
|
||||
{:ok, _blocked_direct} =
|
||||
CommonAPI.post(blocked, %{
|
||||
|
|
|
|||
|
|
@ -190,9 +190,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
|
||||
{:ok, user} = User.follow(user, other_user)
|
||||
{:ok, other_user} = User.follow(other_user, user)
|
||||
{:ok, other_user} = User.subscribe(user, other_user)
|
||||
{:ok, user} = User.mute(user, other_user, true)
|
||||
{:ok, user} = CommonAPI.hide_reblogs(user, other_user)
|
||||
{:ok, _subscription} = User.subscribe(user, other_user)
|
||||
{:ok, _user_relationships} = User.mute(user, other_user, true)
|
||||
{:ok, _reblog_mute} = CommonAPI.hide_reblogs(user, other_user)
|
||||
|
||||
expected = %{
|
||||
id: to_string(other_user.id),
|
||||
|
|
@ -218,9 +218,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, user} = User.follow(user, other_user)
|
||||
{:ok, other_user} = User.subscribe(user, other_user)
|
||||
{:ok, user} = User.block(user, other_user)
|
||||
{:ok, other_user} = User.block(other_user, user)
|
||||
{:ok, _subscription} = User.subscribe(user, other_user)
|
||||
{:ok, _user_relationship} = User.block(user, other_user)
|
||||
{:ok, _user_relationship} = User.block(other_user, user)
|
||||
|
||||
expected = %{
|
||||
id: to_string(other_user.id),
|
||||
|
|
@ -291,7 +291,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
|
||||
other_user = insert(:user)
|
||||
{:ok, other_user} = User.follow(other_user, user)
|
||||
{:ok, other_user} = User.block(other_user, user)
|
||||
{:ok, _user_relationship} = User.block(other_user, user)
|
||||
{:ok, _} = User.follow(insert(:user), user)
|
||||
|
||||
expected = %{
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
end
|
||||
|
||||
test "Move notification" do
|
||||
%{ap_id: old_ap_id} = old_user = insert(:user)
|
||||
%{ap_id: _new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id])
|
||||
old_user = insert(:user)
|
||||
new_user = insert(:user, also_known_as: [old_user.ap_id])
|
||||
follower = insert(:user)
|
||||
|
||||
User.follow(follower, old_user)
|
||||
|
|
@ -120,7 +120,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
old_user = refresh_record(old_user)
|
||||
new_user = refresh_record(new_user)
|
||||
|
||||
[notification] = Notification.for_user(follower)
|
||||
[notification] = Notification.for_user(follower, %{with_move: true})
|
||||
|
||||
expected = %{
|
||||
id: to_string(notification.id),
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, user} = User.mute(user, other_user)
|
||||
{:ok, _user_relationships} = User.mute(user, other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
|
||||
status = StatusView.render("show.json", %{activity: activity})
|
||||
|
|
@ -199,7 +199,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, user} = User.mute(user, other_user)
|
||||
{:ok, _user_relationships} = User.mute(user, other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
|
||||
status = StatusView.render("show.json", %{activity: activity, for: user})
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
user: user
|
||||
} do
|
||||
blocked = insert(:user)
|
||||
{:ok, user} = User.block(user, blocked)
|
||||
{:ok, _user_relationship} = User.block(user, blocked)
|
||||
|
||||
task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "it doesn't send messages involving blocked users" do
|
||||
user = insert(:user)
|
||||
blocked_user = insert(:user)
|
||||
{:ok, user} = User.block(user, blocked_user)
|
||||
{:ok, _user_relationship} = User.block(user, blocked_user)
|
||||
|
||||
task =
|
||||
Task.async(fn ->
|
||||
|
|
@ -301,7 +301,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
"public" => [fake_socket]
|
||||
}
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blockee)
|
||||
{:ok, _user_relationship} = User.block(blocker, blockee)
|
||||
|
||||
{:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey! @#{blockee.nickname}"})
|
||||
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
|
||||
{:ok, _user} = Pleroma.User.block(user2, user)
|
||||
{:ok, _user_block} = Pleroma.User.block(user2, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -485,7 +485,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
Pleroma.Config.put([:user, :deny_follow_blocked], true)
|
||||
user = insert(:user)
|
||||
user2 = insert(:user)
|
||||
{:ok, _user} = Pleroma.User.block(user2, user)
|
||||
{:ok, _user_block} = Pleroma.User.block(user2, user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue