Use User.get_cached* everywhere
This commit is contained in:
parent
05862ded7a
commit
b9cdf6d3b9
42 changed files with 255 additions and 229 deletions
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.NotificationTest do
|
|||
describe "create_notification" do
|
||||
test "it doesn't create a notification for user if the user blocks the activity author" do
|
||||
activity = insert(:note_activity)
|
||||
author = User.get_by_ap_id(activity.data["actor"])
|
||||
author = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
user = insert(:user)
|
||||
{:ok, user} = User.block(user, author)
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ defmodule Pleroma.NotificationTest do
|
|||
|
||||
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"])
|
||||
author = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
|
||||
assert nil == Notification.create_notification(activity, author)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
|
|||
local_user = Relay.get_actor()
|
||||
assert local_user.ap_id =~ "/relay"
|
||||
|
||||
target_user = User.get_by_ap_id(target_instance)
|
||||
target_user = User.get_cached_by_ap_id(target_instance)
|
||||
refute target_user.local
|
||||
|
||||
activity = Utils.fetch_latest_follow(local_user, target_user)
|
||||
|
|
@ -48,7 +48,7 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
|
|||
Mix.Tasks.Pleroma.Relay.run(["follow", target_instance])
|
||||
|
||||
%User{ap_id: follower_id} = local_user = Relay.get_actor()
|
||||
target_user = User.get_by_ap_id(target_instance)
|
||||
target_user = User.get_cached_by_ap_id(target_instance)
|
||||
follow_activity = Utils.fetch_latest_follow(local_user, target_user)
|
||||
|
||||
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ "created"
|
||||
|
||||
user = User.get_by_nickname(unsaved.nickname)
|
||||
user = User.get_cached_by_nickname(unsaved.nickname)
|
||||
assert user.name == unsaved.name
|
||||
assert user.email == unsaved.email
|
||||
assert user.bio == unsaved.bio
|
||||
|
|
@ -75,7 +75,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ "will not be created"
|
||||
|
||||
refute User.get_by_nickname(unsaved.nickname)
|
||||
refute User.get_cached_by_nickname(unsaved.nickname)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ " deleted"
|
||||
|
||||
user = User.get_by_nickname(user.nickname)
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.info.deactivated
|
||||
end
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ " deactivated"
|
||||
|
||||
user = User.get_by_nickname(user.nickname)
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.info.deactivated
|
||||
end
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ " activated"
|
||||
|
||||
user = User.get_by_nickname(user.nickname)
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
refute user.info.deactivated
|
||||
end
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ "Successfully unsubscribed"
|
||||
|
||||
user = User.get_by_nickname(user.nickname)
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert Enum.empty?(user.following)
|
||||
assert user.info.deactivated
|
||||
end
|
||||
|
|
@ -178,7 +178,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Admin status .* true/
|
||||
|
||||
user = User.get_by_nickname(user.nickname)
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
assert user.info.is_moderator
|
||||
assert user.info.locked
|
||||
assert user.info.is_admin
|
||||
|
|
@ -204,7 +204,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message =~ ~r/Admin status .* false/
|
||||
|
||||
user = User.get_by_nickname(user.nickname)
|
||||
user = User.get_cached_by_nickname(user.nickname)
|
||||
refute user.info.is_moderator
|
||||
refute user.info.locked
|
||||
refute user.info.is_admin
|
||||
|
|
|
|||
|
|
@ -123,9 +123,9 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user} = User.follow(user, followed)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
followed = User.get_by_ap_id(followed.ap_id)
|
||||
followed = User.get_cached_by_ap_id(followed.ap_id)
|
||||
assert followed.info.follower_count == 1
|
||||
|
||||
assert User.ap_followers(followed) in user.following
|
||||
|
|
@ -188,7 +188,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user, _activity} = User.unfollow(user, followed)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert user.following == []
|
||||
end
|
||||
|
|
@ -198,7 +198,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:error, _} = User.unfollow(user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.following == [user.ap_id]
|
||||
end
|
||||
|
||||
|
|
@ -556,8 +556,8 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, res} = User.get_friends(user)
|
||||
|
||||
followed_one = User.get_by_ap_id(followed_one.ap_id)
|
||||
followed_two = User.get_by_ap_id(followed_two.ap_id)
|
||||
followed_one = User.get_cached_by_ap_id(followed_one.ap_id)
|
||||
followed_two = User.get_cached_by_ap_id(followed_two.ap_id)
|
||||
assert Enum.member?(res, followed_one)
|
||||
assert Enum.member?(res, followed_two)
|
||||
refute Enum.member?(res, not_followed)
|
||||
|
|
@ -568,7 +568,7 @@ defmodule Pleroma.UserTest do
|
|||
test "it sets the info->note_count property" do
|
||||
note = insert(:note)
|
||||
|
||||
user = User.get_by_ap_id(note.data["actor"])
|
||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
|
||||
assert user.info.note_count == 0
|
||||
|
||||
|
|
@ -579,7 +579,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
test "it increases the info->note_count property" do
|
||||
note = insert(:note)
|
||||
user = User.get_by_ap_id(note.data["actor"])
|
||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
|
||||
assert user.info.note_count == 0
|
||||
|
||||
|
|
@ -594,7 +594,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
test "it decreases the info->note_count property" do
|
||||
note = insert(:note)
|
||||
user = User.get_by_ap_id(note.data["actor"])
|
||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
|
||||
assert user.info.note_count == 0
|
||||
|
||||
|
|
@ -696,7 +696,7 @@ defmodule Pleroma.UserTest do
|
|||
assert User.following?(blocked, blocker)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
blocked = User.get_by_id(blocked.id)
|
||||
blocked = User.get_cached_by_id(blocked.id)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -714,7 +714,7 @@ defmodule Pleroma.UserTest do
|
|||
refute User.following?(blocked, blocker)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
blocked = User.get_by_id(blocked.id)
|
||||
blocked = User.get_cached_by_id(blocked.id)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -732,7 +732,7 @@ defmodule Pleroma.UserTest do
|
|||
assert User.following?(blocked, blocker)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
blocked = User.get_by_id(blocked.id)
|
||||
blocked = User.get_cached_by_id(blocked.id)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -852,9 +852,9 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, _} = User.delete(user)
|
||||
|
||||
followed = User.get_by_id(followed.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
user = User.get_by_id(user.id)
|
||||
followed = User.get_cached_by_id(followed.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert user.info.deactivated
|
||||
|
||||
|
|
@ -1008,7 +1008,7 @@ defmodule Pleroma.UserTest do
|
|||
results = User.search("http://mastodon.example.org/users/admin", resolve: true)
|
||||
result = results |> List.first()
|
||||
|
||||
user = User.get_by_ap_id("http://mastodon.example.org/users/admin")
|
||||
user = User.get_cached_by_ap_id("http://mastodon.example.org/users/admin")
|
||||
|
||||
assert length(results) == 1
|
||||
assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|> put_req_header("accept", "application/json")
|
||||
|> get("/users/#{user.nickname}")
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
|
||||
end
|
||||
|
|
@ -65,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|> put_req_header("accept", "application/activity+json")
|
||||
|> get("/users/#{user.nickname}")
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
|
||||
end
|
||||
|
|
@ -83,7 +83,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
)
|
||||
|> get("/users/#{user.nickname}")
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
|
||||
end
|
||||
|
|
@ -572,7 +572,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
user = insert(:user)
|
||||
|
||||
Enum.each(1..15, fn _ ->
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = insert(:user)
|
||||
User.follow(user, other_user)
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -228,18 +228,30 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "1", "visibility" => "public"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "1",
|
||||
"visibility" => "public"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "2", "visibility" => "unlisted"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "2",
|
||||
"visibility" => "unlisted"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "2", "visibility" => "private"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "2",
|
||||
"visibility" => "private"
|
||||
})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "3", "visibility" => "direct"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "3",
|
||||
"visibility" => "direct"
|
||||
})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.info.note_count == 2
|
||||
end
|
||||
|
||||
|
|
@ -772,23 +784,35 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
user = insert(:user, info: %{note_count: 10})
|
||||
|
||||
{:ok, a1} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "public"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "yeah",
|
||||
"visibility" => "public"
|
||||
})
|
||||
|
||||
{:ok, a2} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "unlisted"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "yeah",
|
||||
"visibility" => "unlisted"
|
||||
})
|
||||
|
||||
{:ok, a3} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "private"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "yeah",
|
||||
"visibility" => "private"
|
||||
})
|
||||
|
||||
{:ok, a4} =
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "direct"})
|
||||
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
||||
"status" => "yeah",
|
||||
"visibility" => "direct"
|
||||
})
|
||||
|
||||
{:ok, _} = Object.normalize(a1) |> ActivityPub.delete()
|
||||
{:ok, _} = Object.normalize(a2) |> ActivityPub.delete()
|
||||
{:ok, _} = Object.normalize(a3) |> ActivityPub.delete()
|
||||
{:ok, _} = Object.normalize(a4) |> ActivityPub.delete()
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.info.note_count == 10
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
assert object["sensitive"] == true
|
||||
|
||||
user = User.get_by_ap_id(object["actor"])
|
||||
user = User.get_cached_by_ap_id(object["actor"])
|
||||
|
||||
assert user.info.note_count == 1
|
||||
end
|
||||
|
|
@ -212,7 +212,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||
assert data["type"] == "Follow"
|
||||
assert data["id"] == "http://mastodon.example.org/users/admin#follows/2"
|
||||
assert User.following?(User.get_by_ap_id(data["actor"]), user)
|
||||
assert User.following?(User.get_cached_by_ap_id(data["actor"]), user)
|
||||
end
|
||||
|
||||
test "it works for incoming follow requests from hubzilla" do
|
||||
|
|
@ -229,7 +229,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["actor"] == "https://hubzilla.example.org/channel/kaniini"
|
||||
assert data["type"] == "Follow"
|
||||
assert data["id"] == "https://hubzilla.example.org/channel/kaniini#follows/2"
|
||||
assert User.following?(User.get_by_ap_id(data["actor"]), user)
|
||||
assert User.following?(User.get_cached_by_ap_id(data["actor"]), user)
|
||||
end
|
||||
|
||||
test "it works for incoming likes" do
|
||||
|
|
@ -540,7 +540,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["object"]["object"] == user.ap_id
|
||||
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||
|
||||
refute User.following?(User.get_by_ap_id(data["actor"]), user)
|
||||
refute User.following?(User.get_cached_by_ap_id(data["actor"]), user)
|
||||
end
|
||||
|
||||
test "it works for incoming blocks" do
|
||||
|
|
@ -557,7 +557,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["object"] == user.ap_id
|
||||
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||
|
||||
blocker = User.get_by_ap_id(data["actor"])
|
||||
blocker = User.get_cached_by_ap_id(data["actor"])
|
||||
|
||||
assert User.blocks?(blocker, user)
|
||||
end
|
||||
|
|
@ -584,8 +584,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["object"] == blocked.ap_id
|
||||
assert data["actor"] == blocker.ap_id
|
||||
|
||||
blocker = User.get_by_ap_id(data["actor"])
|
||||
blocked = User.get_by_ap_id(data["object"])
|
||||
blocker = User.get_cached_by_ap_id(data["actor"])
|
||||
blocked = User.get_cached_by_ap_id(data["object"])
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -614,7 +614,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert data["object"]["object"] == user.ap_id
|
||||
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||
|
||||
blocker = User.get_by_ap_id(data["actor"])
|
||||
blocker = User.get_cached_by_ap_id(data["actor"])
|
||||
|
||||
refute User.blocks?(blocker, user)
|
||||
end
|
||||
|
|
@ -645,7 +645,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -667,7 +667,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -687,7 +687,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -706,7 +706,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
:error = Transmogrifier.handle_incoming(accept_data)
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -725,7 +725,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
:error = Transmogrifier.handle_incoming(accept_data)
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -750,7 +750,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = Transmogrifier.handle_incoming(reject_data)
|
||||
refute activity.local
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == false
|
||||
end
|
||||
|
|
@ -772,7 +772,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, %Activity{data: _}} = Transmogrifier.handle_incoming(reject_data)
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == false
|
||||
end
|
||||
|
|
@ -1026,7 +1026,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
|
||||
assert "http://localhost:4001/users/rye@niu.moe/followers" in activity.recipients
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.info.note_count == 1
|
||||
|
||||
{:ok, user} = Transmogrifier.upgrade_user_from_ap_id("https://niu.moe/users/rye")
|
||||
|
|
@ -1034,7 +1034,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert user.info.note_count == 1
|
||||
assert user.follower_address == "https://niu.moe/users/rye/followers"
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.info.note_count == 1
|
||||
|
||||
activity = Activity.get_by_id(activity.id)
|
||||
|
|
@ -1063,7 +1063,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
unrelated_activity = Activity.get_by_id(unrelated_activity.id)
|
||||
refute user.follower_address in unrelated_activity.recipients
|
||||
|
||||
user_two = User.get_by_id(user_two.id)
|
||||
user_two = User.get_cached_by_id(user_two.id)
|
||||
assert user.follower_address in user_two.following
|
||||
refute "..." in user_two.following
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
||||
use Pleroma.DataCase
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
|
|
@ -12,8 +11,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
describe "fetch the latest Follow" do
|
||||
test "fetches the latest Follow activity" do
|
||||
%Activity{data: %{"type" => "Follow"}} = activity = insert(:follow_activity)
|
||||
follower = Repo.get_by(User, ap_id: activity.data["actor"])
|
||||
followed = Repo.get_by(User, ap_id: activity.data["object"])
|
||||
follower = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
followed = User.get_cached_by_ap_id(activity.data["object"])
|
||||
|
||||
assert activity == Utils.fetch_latest_follow(follower, followed)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"followed" => user.nickname
|
||||
})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, user)
|
||||
end
|
||||
|
|
@ -112,8 +112,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"followed" => user.nickname
|
||||
})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, user)
|
||||
end
|
||||
|
|
@ -145,13 +145,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
user2: user2
|
||||
} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert User.get_by_id(user1.id).tags == ["x", "foo", "bar"]
|
||||
assert User.get_by_id(user2.id).tags == ["y", "foo", "bar"]
|
||||
assert User.get_cached_by_id(user1.id).tags == ["x", "foo", "bar"]
|
||||
assert User.get_cached_by_id(user2.id).tags == ["y", "foo", "bar"]
|
||||
end
|
||||
|
||||
test "it does not modify tags of not specified users", %{conn: conn, user3: user3} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert User.get_by_id(user3.id).tags == ["unchanged"]
|
||||
assert User.get_cached_by_id(user3.id).tags == ["unchanged"]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -181,13 +181,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
user2: user2
|
||||
} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert User.get_by_id(user1.id).tags == []
|
||||
assert User.get_by_id(user2.id).tags == ["y"]
|
||||
assert User.get_cached_by_id(user1.id).tags == []
|
||||
assert User.get_cached_by_id(user2.id).tags == ["y"]
|
||||
end
|
||||
|
||||
test "it does not modify tags of not specified users", %{conn: conn, user3: user3} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert User.get_by_id(user3.id).tags == ["unchanged"]
|
||||
assert User.get_cached_by_id(user3.id).tags == ["unchanged"]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
conn
|
||||
|> put("/api/pleroma/admin/activation_status/#{user.nickname}", %{status: false})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.info.deactivated == true
|
||||
assert json_response(conn, :no_content)
|
||||
end
|
||||
|
|
@ -269,7 +269,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
conn
|
||||
|> put("/api/pleroma/admin/activation_status/#{user.nickname}", %{status: true})
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
assert user.info.deactivated == false
|
||||
assert json_response(conn, :no_content)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -169,15 +169,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
test "represent an embedded relationship" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
info: %{note_count: 5, follower_count: 3, source_data: %{"type" => "Service"}},
|
||||
info: %{note_count: 5, follower_count: 0, source_data: %{"type" => "Service"}},
|
||||
nickname: "shp@shitposter.club",
|
||||
inserted_at: ~N[2017-08-15 15:47:06.597036]
|
||||
})
|
||||
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, other_user} = User.follow(other_user, user)
|
||||
{:ok, other_user} = User.block(other_user, user)
|
||||
{:ok, _} = User.follow(insert(:user), user)
|
||||
|
||||
expected = %{
|
||||
id: to_string(user.id),
|
||||
|
|
@ -186,7 +186,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
display_name: user.name,
|
||||
locked: false,
|
||||
created_at: "2017-08-15T15:47:06.000Z",
|
||||
followers_count: 3,
|
||||
followers_count: 1,
|
||||
following_count: 0,
|
||||
statuses_count: 5,
|
||||
note: user.bio,
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
describe "deleting a status" do
|
||||
test "when you created it", %{conn: conn} do
|
||||
activity = insert(:note_activity)
|
||||
author = User.get_by_ap_id(activity.data["actor"])
|
||||
author = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -1167,7 +1167,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
test "unimplemented pinned statuses feature", %{conn: conn} do
|
||||
note = insert(:note_activity)
|
||||
user = User.get_by_ap_id(note.data["actor"])
|
||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -1178,7 +1178,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
test "gets an users media", %{conn: conn} do
|
||||
note = insert(:note_activity)
|
||||
user = User.get_by_ap_id(note.data["actor"])
|
||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
|
|
@ -1253,8 +1253,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1273,8 +1273,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1286,8 +1286,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert relationship = json_response(conn, 200)
|
||||
assert to_string(other_user.id) == relationship["id"]
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == true
|
||||
end
|
||||
|
|
@ -1310,7 +1310,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1320,8 +1320,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert relationship = json_response(conn, 200)
|
||||
assert to_string(other_user.id) == relationship["id"]
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
end
|
||||
|
|
@ -1606,7 +1606,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "following" => true} = json_response(conn, 200)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1615,7 +1615,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "following" => false} = json_response(conn, 200)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1709,7 +1709,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "muting" => true} = json_response(conn, 200)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1764,7 +1764,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "blocking" => true} = json_response(conn, 200)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -2124,7 +2124,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
{:ok, _} = TwitterAPI.create_status(user, %{"status" => "cofe"})
|
||||
|
||||
# Stats should count users with missing or nil `info.deactivated` value
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
info_change = Changeset.change(user.info, %{deactivated: nil})
|
||||
|
||||
{:ok, _user} =
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
mentioned_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{mentioned_user.nickname}"})
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
expected = %{
|
||||
id: to_string(notification.id),
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
status = StatusView.render("status.json", %{activity: activity})
|
||||
|
||||
actor = User.get_by_ap_id(activity.actor)
|
||||
actor = User.get_cached_by_ap_id(activity.actor)
|
||||
|
||||
assert status.mentions ==
|
||||
Enum.map([user, actor], fn u -> AccountView.render("mention.json", %{user: u}) end)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
import Pleroma.Factory
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.OStatus.ActivityRepresenter
|
||||
|
|
@ -41,7 +40,8 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
assert response(conn, 200)
|
||||
|
||||
# Set a wrong magic-key for a user so it has to refetch
|
||||
salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
|
||||
salmon_user = User.get_cached_by_ap_id("http://gs.example.org:4040/index.php/user/1")
|
||||
|
||||
# Wrong key
|
||||
info_cng =
|
||||
User.Info.remote_user_creation(salmon_user.info, %{
|
||||
|
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
salmon_user
|
||||
|> Ecto.Changeset.change()
|
||||
|> Ecto.Changeset.put_embed(:info, info_cng)
|
||||
|> Repo.update()
|
||||
|> User.update_and_set_cache()
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -86,7 +86,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
|
||||
test "gets an object", %{conn: conn} do
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_by_ap_id(note_activity.data["actor"])
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"]))
|
||||
url = "/objects/#{uuid}"
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
object = Object.normalize(activity.data["object"])
|
||||
|
||||
user = User.get_by_ap_id(activity.data["actor"])
|
||||
user = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
assert user.info.note_count == 1
|
||||
assert activity.data["type"] == "Create"
|
||||
assert object.data["type"] == "Note"
|
||||
|
|
@ -296,8 +296,8 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert activity.data["object"] == "https://pawoo.net/users/pekorino"
|
||||
refute activity.local
|
||||
|
||||
follower = User.get_by_ap_id(activity.data["actor"])
|
||||
followed = User.get_by_ap_id(activity.data["object"])
|
||||
follower = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
followed = User.get_cached_by_ap_id(activity.data["object"])
|
||||
|
||||
assert User.following?(follower, followed)
|
||||
end
|
||||
|
|
@ -320,8 +320,8 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert activity.data["object"]["object"] == "https://pawoo.net/users/pekorino"
|
||||
refute activity.local
|
||||
|
||||
follower = User.get_by_ap_id(activity.data["actor"])
|
||||
followed = User.get_by_ap_id(activity.data["object"]["object"])
|
||||
follower = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
followed = User.get_cached_by_ap_id(activity.data["object"]["object"])
|
||||
|
||||
refute User.following?(follower, followed)
|
||||
end
|
||||
|
|
@ -355,7 +355,7 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
|
||||
{:ok, user} = OStatus.find_or_make_user(uri)
|
||||
|
||||
user = Pleroma.User.get_by_id(user.id)
|
||||
user = Pleroma.User.get_cached_by_id(user.id)
|
||||
assert user.name == "Constance Variable"
|
||||
assert user.nickname == "lambadalambda@social.heldscal.la"
|
||||
assert user.local == false
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ defmodule Pleroma.Web.Salmon.SalmonTest do
|
|||
}
|
||||
|
||||
{:ok, activity} = Repo.insert(%Activity{data: activity_data, recipients: activity_data["to"]})
|
||||
user = User.get_by_ap_id(activity.data["actor"])
|
||||
user = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
{:ok, user} = Pleroma.Web.WebFinger.ensure_keys_present(user)
|
||||
|
||||
poster = fn url, _data, _headers ->
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
test "returns one status", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey!"})
|
||||
actor = Repo.get_by!(User, ap_id: activity.data["actor"])
|
||||
actor = User.get_cached_by_ap_id(activity.data["actor"])
|
||||
|
||||
conn =
|
||||
conn
|
||||
|
|
@ -720,7 +720,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/create.json", %{user_id: followed.id})
|
||||
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
current_user = User.get_cached_by_id(current_user.id)
|
||||
assert User.ap_followers(followed) in current_user.following
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -735,8 +735,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/create.json", %{user_id: followed.id})
|
||||
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
followed = User.get_by_id(followed.id)
|
||||
current_user = User.get_cached_by_id(current_user.id)
|
||||
followed = User.get_cached_by_id(followed.id)
|
||||
|
||||
refute User.ap_followers(followed) in current_user.following
|
||||
|
||||
|
|
@ -765,7 +765,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/destroy.json", %{user_id: followed.id})
|
||||
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
current_user = User.get_cached_by_id(current_user.id)
|
||||
assert current_user.following == [current_user.ap_id]
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -789,7 +789,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/blocks/create.json", %{user_id: blocked.id})
|
||||
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
current_user = User.get_cached_by_id(current_user.id)
|
||||
assert User.blocks?(current_user, blocked)
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -816,7 +816,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/blocks/destroy.json", %{user_id: blocked.id})
|
||||
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
current_user = User.get_cached_by_id(current_user.id)
|
||||
assert current_user.info.blocks == []
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -847,7 +847,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/qvitter/update_avatar.json", %{img: avatar_image})
|
||||
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
current_user = User.get_cached_by_id(current_user.id)
|
||||
assert is_map(current_user.avatar)
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -956,7 +956,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> post(request_path)
|
||||
|
||||
activity = Activity.get_by_id(note_activity.id)
|
||||
activity_user = User.get_by_ap_id(note_activity.data["actor"])
|
||||
activity_user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
|
||||
assert json_response(response, 200) ==
|
||||
ActivityView.render("activity.json", %{
|
||||
|
|
@ -994,7 +994,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> post(request_path)
|
||||
|
||||
activity = Activity.get_by_id(note_activity.id)
|
||||
activity_user = User.get_by_ap_id(note_activity.data["actor"])
|
||||
activity_user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
|
||||
assert json_response(response, 200) ==
|
||||
ActivityView.render("activity.json", %{
|
||||
|
|
@ -1022,7 +1022,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
user = json_response(conn, 200)
|
||||
|
||||
fetched_user = User.get_by_nickname("lain")
|
||||
fetched_user = User.get_cached_by_nickname("lain")
|
||||
assert user == UserView.render("show.json", %{user: fetched_user})
|
||||
end
|
||||
|
||||
|
|
@ -1116,7 +1116,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
test "it confirms the user account", %{conn: conn, user: user} do
|
||||
get(conn, "/api/account/confirm_email/#{user.id}/#{user.info.confirmation_token}")
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
refute user.info.confirmation_pending
|
||||
refute user.info.confirmation_token
|
||||
|
|
@ -1742,7 +1742,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
})
|
||||
|
||||
assert json_response(conn, 200) == %{"status" => "success"}
|
||||
fetched_user = User.get_by_id(current_user.id)
|
||||
fetched_user = User.get_cached_by_id(current_user.id)
|
||||
assert Pbkdf2.checkpw("newpass", fetched_user.password_hash) == true
|
||||
end
|
||||
end
|
||||
|
|
@ -1783,8 +1783,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1823,8 +1823,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1846,8 +1846,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1916,7 +1916,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
describe "POST /api/media/metadata/create" do
|
||||
setup do
|
||||
object = insert(:note)
|
||||
user = User.get_by_ap_id(object.data["actor"])
|
||||
user = User.get_cached_by_ap_id(object.data["actor"])
|
||||
%{object: object, user: user}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
assert activity.data["object"] == object.data["id"]
|
||||
|
||||
user = User.get_by_ap_id(user.ap_id)
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
||||
assert user.info.note_count == 1
|
||||
end
|
||||
|
|
@ -129,7 +129,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
assert User.ap_followers(followed) in user.following
|
||||
|
||||
followed = User.get_by_ap_id(followed.ap_id)
|
||||
followed = User.get_cached_by_ap_id(followed.ap_id)
|
||||
assert followed.info.follower_count == 1
|
||||
|
||||
{:error, msg} = TwitterAPI.follow(user, %{"screen_name" => followed.nickname})
|
||||
|
|
@ -281,7 +281,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
|
||||
fetched_user = User.get_by_nickname("lain")
|
||||
fetched_user = User.get_cached_by_nickname("lain")
|
||||
|
||||
assert UserView.render("show.json", %{user: user}) ==
|
||||
UserView.render("show.json", %{user: fetched_user})
|
||||
|
|
@ -299,7 +299,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
|
||||
fetched_user = User.get_by_nickname("lain")
|
||||
fetched_user = User.get_cached_by_nickname("lain")
|
||||
|
||||
assert UserView.render("show.json", %{user: user}) ==
|
||||
UserView.render("show.json", %{user: fetched_user})
|
||||
|
|
@ -394,7 +394,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
|
||||
fetched_user = User.get_by_nickname("vinny")
|
||||
fetched_user = User.get_cached_by_nickname("vinny")
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
||||
assert invite.used == true
|
||||
|
|
@ -417,7 +417,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Invalid token"
|
||||
refute User.get_by_nickname("GrimReaper")
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
end
|
||||
|
||||
test "returns error on expired token" do
|
||||
|
|
@ -437,7 +437,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_by_nickname("GrimReaper")
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -462,7 +462,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
check_fn = fn invite ->
|
||||
data = Map.put(data, "token", invite.token)
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
fetched_user = User.get_by_nickname("vinny")
|
||||
fetched_user = User.get_cached_by_nickname("vinny")
|
||||
|
||||
assert UserView.render("show.json", %{user: user}) ==
|
||||
UserView.render("show.json", %{user: fetched_user})
|
||||
|
|
@ -499,7 +499,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_by_nickname("vinny")
|
||||
refute User.get_cached_by_nickname("vinny")
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
||||
refute invite.used
|
||||
|
|
@ -534,7 +534,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
fetched_user = User.get_by_nickname("vinny")
|
||||
fetched_user = User.get_cached_by_nickname("vinny")
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
||||
assert invite.used == true
|
||||
|
|
@ -555,7 +555,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_by_nickname("GrimReaper")
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -585,7 +585,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
fetched_user = User.get_by_nickname("vinny")
|
||||
fetched_user = User.get_cached_by_nickname("vinny")
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
|
||||
refute invite.used
|
||||
|
|
@ -610,7 +610,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
}
|
||||
|
||||
{:ok, user} = TwitterAPI.register_user(data)
|
||||
fetched_user = User.get_by_nickname("vinny")
|
||||
fetched_user = User.get_cached_by_nickname("vinny")
|
||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||
assert invite.used == true
|
||||
|
||||
|
|
@ -630,7 +630,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_by_nickname("GrimReaper")
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
end
|
||||
|
||||
test "returns error on overdue date" do
|
||||
|
|
@ -650,7 +650,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_by_nickname("GrimReaper")
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
end
|
||||
|
||||
test "returns error on with overdue date and after max" do
|
||||
|
|
@ -672,7 +672,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, msg} = TwitterAPI.register_user(data)
|
||||
|
||||
assert msg == "Expired token"
|
||||
refute User.get_by_nickname("GrimReaper")
|
||||
refute User.get_cached_by_nickname("GrimReaper")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -688,7 +688,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:error, error_object} = TwitterAPI.register_user(data)
|
||||
|
||||
assert is_binary(error_object[:error])
|
||||
refute User.get_by_nickname("lain")
|
||||
refute User.get_cached_by_nickname("lain")
|
||||
end
|
||||
|
||||
test "it assigns an integer conversation_id" do
|
||||
|
|
@ -709,7 +709,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
id = "https://mastodon.social/users/lambadalambda"
|
||||
user = insert(:user)
|
||||
{:ok, represented} = TwitterAPI.get_external_profile(user, id)
|
||||
remote = User.get_by_ap_id(id)
|
||||
remote = User.get_cached_by_ap_id(id)
|
||||
|
||||
assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"]
|
||||
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
}
|
||||
}
|
||||
|
||||
blocker = User.get_by_id(blocker.id)
|
||||
blocker = User.get_cached_by_id(blocker.id)
|
||||
assert represented == UserView.render("show.json", %{user: user, for: blocker})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue