Merge branch 'develop' into issue/1276
This commit is contained in:
commit
b27a92e8fa
66 changed files with 1283 additions and 377 deletions
|
|
@ -693,7 +693,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
{:ok, announce, _object} = CommonAPI.repeat(activity_three.id, booster)
|
||||
|
||||
[announce_activity] = ActivityPub.fetch_activities([user.ap_id | user.following])
|
||||
[announce_activity] = ActivityPub.fetch_activities([user.ap_id | User.following(user)])
|
||||
|
||||
assert announce_activity.id == announce.id
|
||||
end
|
||||
|
|
@ -1219,7 +1219,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
})
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([user1.ap_id | user1.following])
|
||||
ActivityPub.fetch_activities([user1.ap_id | User.following(user1)])
|
||||
|> Enum.map(fn a -> a.id end)
|
||||
|
||||
private_activity_1 = Activity.get_by_ap_id_with_object(private_activity_1.data["id"])
|
||||
|
|
@ -1229,7 +1229,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert length(activities) == 3
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([user1.ap_id | user1.following], %{"user" => user1})
|
||||
ActivityPub.fetch_activities([user1.ap_id | User.following(user1)], %{"user" => user1})
|
||||
|> Enum.map(fn a -> a.id end)
|
||||
|
||||
assert [public_activity.id, private_activity_1.id] == activities
|
||||
|
|
|
|||
|
|
@ -56,14 +56,14 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
|
|||
service_actor = Relay.get_actor()
|
||||
ActivityPub.follow(service_actor, user)
|
||||
Pleroma.User.follow(service_actor, user)
|
||||
assert "#{user.ap_id}/followers" in refresh_record(service_actor).following
|
||||
assert "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
assert {:ok, %Activity{} = activity} = Relay.unfollow(user.ap_id)
|
||||
assert activity.actor == "#{Pleroma.Web.Endpoint.url()}/relay"
|
||||
assert user.ap_id in activity.recipients
|
||||
assert activity.data["type"] == "Undo"
|
||||
assert activity.data["actor"] == service_actor.ap_id
|
||||
assert activity.data["to"] == [user.ap_id]
|
||||
refute "#{user.ap_id}/followers" in refresh_record(service_actor).following
|
||||
refute "#{user.ap_id}/followers" in User.following(service_actor)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -720,7 +720,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert capture_log(fn ->
|
||||
:error = Transmogrifier.handle_incoming(data)
|
||||
end) =~
|
||||
"[error] Could not decode user at fetch http://mastodon.example.org/users/gargron, {:error, {:error, :nxdomain}}"
|
||||
"[error] Could not decode user at fetch http://mastodon.example.org/users/gargron, {:error, :nxdomain}"
|
||||
|
||||
assert Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
|
@ -804,6 +804,25 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
refute User.following?(User.get_cached_by_ap_id(data["actor"]), user)
|
||||
end
|
||||
|
||||
test "it works for incoming follows to locked account" do
|
||||
pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
|
||||
user = insert(:user, locked: true)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("object", user.ap_id)
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["type"] == "Follow"
|
||||
assert data["object"] == user.ap_id
|
||||
assert data["state"] == "pending"
|
||||
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||
|
||||
assert [^pending_follower] = User.get_follow_requests(user)
|
||||
end
|
||||
|
||||
test "it works for incoming blocks" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -1334,7 +1353,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
follower_address: User.ap_followers(%User{nickname: "rye@niu.moe"})
|
||||
})
|
||||
|
||||
user_two = insert(:user, %{following: [user.follower_address]})
|
||||
user_two = insert(:user)
|
||||
Pleroma.FollowingRelationship.follow(user_two, user, "accept")
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
|
||||
|
|
@ -1381,8 +1401,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
refute user.follower_address in unrelated_activity.recipients
|
||||
|
||||
user_two = User.get_cached_by_id(user_two.id)
|
||||
assert user.follower_address in user_two.following
|
||||
refute "..." in user_two.following
|
||||
assert User.following?(user_two, user)
|
||||
refute "..." in User.following(user_two)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,8 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
|
|||
|
||||
test "returns true if user following to author" do
|
||||
author = insert(:user)
|
||||
user = insert(:user, following: [author.ap_id])
|
||||
user = insert(:user)
|
||||
Pleroma.User.follow(user, author)
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
|
|||
|
|
@ -2572,22 +2572,20 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
test "GET /relay", %{admin: admin} do
|
||||
Pleroma.Web.ActivityPub.Relay.get_actor()
|
||||
|> Ecto.Changeset.change(
|
||||
following: [
|
||||
"http://test-app.com/user/test1",
|
||||
"http://test-app.com/user/test1",
|
||||
"http://test-app-42.com/user/test1"
|
||||
]
|
||||
)
|
||||
|> Pleroma.User.update_and_set_cache()
|
||||
relay_user = Pleroma.Web.ActivityPub.Relay.get_actor()
|
||||
|
||||
["http://mastodon.example.org/users/admin", "https://mstdn.io/users/mayuutann"]
|
||||
|> Enum.each(fn ap_id ->
|
||||
{:ok, user} = User.get_or_fetch_by_ap_id(ap_id)
|
||||
User.follow(relay_user, user)
|
||||
end)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, admin)
|
||||
|> get("/api/pleroma/admin/relay")
|
||||
|
||||
assert json_response(conn, 200)["relays"] -- ["test-app.com", "test-app-42.com"] == []
|
||||
assert json_response(conn, 200)["relays"] -- ["mastodon.example.org", "mstdn.io"] == []
|
||||
end
|
||||
|
||||
test "DELETE /relay", %{admin: admin} do
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, follower)
|
||||
|> assign(:user, User.get_cached_by_id(follower.id))
|
||||
|> post("/api/v1/accounts/#{followed.id}/follow?reblogs=true")
|
||||
|
||||
assert %{"showing_reblogs" => true} = json_response(conn, 200)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
{:ok, other_user} = User.follow(other_user, user, "pending")
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -36,6 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
{:ok, other_user} = User.follow(other_user, user, "pending")
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
|
|
|||
|
|
@ -169,7 +169,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "it doesn't send to user if recipients invalid and thread containment is enabled" do
|
||||
Pleroma.Config.put([:instance, :skip_thread_containment], false)
|
||||
author = insert(:user)
|
||||
user = insert(:user, following: [author.ap_id])
|
||||
user = insert(:user)
|
||||
User.follow(user, author, "accept")
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
@ -191,7 +192,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "it sends message if recipients invalid and thread containment is disabled" do
|
||||
Pleroma.Config.put([:instance, :skip_thread_containment], true)
|
||||
author = insert(:user)
|
||||
user = insert(:user, following: [author.ap_id])
|
||||
user = insert(:user)
|
||||
User.follow(user, author, "accept")
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
@ -213,7 +215,8 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
test "it sends message if recipients invalid and thread containment is enabled but user's thread containment is disabled" do
|
||||
Pleroma.Config.put([:instance, :skip_thread_containment], false)
|
||||
author = insert(:user)
|
||||
user = insert(:user, following: [author.ap_id], skip_thread_containment: true)
|
||||
user = insert(:user, skip_thread_containment: true)
|
||||
User.follow(user, author, "accept")
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
assert user2.follower_address in refresh_record(user).following
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
test "returns error when user is deactivated", %{conn: conn} do
|
||||
|
|
@ -438,7 +438,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
|> response(200)
|
||||
|
||||
assert response =~ "Account followed!"
|
||||
assert user2.follower_address in refresh_record(user).following
|
||||
assert user2.follower_address in User.following(user)
|
||||
end
|
||||
|
||||
test "returns error when followee not found", %{conn: conn} do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue