Merge branch 'develop' into 'fix/2412-filters'
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
008499f65a
245 changed files with 1917 additions and 905 deletions
|
|
@ -29,6 +29,45 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|> json_response_and_validate_schema(404)
|
||||
end
|
||||
|
||||
test "relationship field" do
|
||||
%{conn: conn, user: user} = oauth_access(["read"])
|
||||
|
||||
other_user = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{other_user.id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response["id"] == other_user.id
|
||||
assert response["pleroma"]["relationship"] == %{}
|
||||
|
||||
assert %{"pleroma" => %{"relationship" => %{"following" => false, "followed_by" => false}}} =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{other_user.id}?with_relationships=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
{:ok, _, %{id: other_id}} = User.follow(user, other_user)
|
||||
|
||||
assert %{
|
||||
"id" => ^other_id,
|
||||
"pleroma" => %{"relationship" => %{"following" => true, "followed_by" => false}}
|
||||
} =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{other_id}?with_relationships=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
{:ok, _, _} = User.follow(other_user, user)
|
||||
|
||||
assert %{
|
||||
"id" => ^other_id,
|
||||
"pleroma" => %{"relationship" => %{"following" => true, "followed_by" => true}}
|
||||
} =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{other_id}?with_relationships=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "works by nickname" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -590,6 +629,45 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert [%{"id" => ^user_id}] = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "following with relationship", %{conn: conn, user: user} do
|
||||
other_user = insert(:user)
|
||||
{:ok, %{id: id}, _} = User.follow(other_user, user)
|
||||
|
||||
assert [
|
||||
%{
|
||||
"id" => ^id,
|
||||
"pleroma" => %{
|
||||
"relationship" => %{
|
||||
"id" => ^id,
|
||||
"following" => false,
|
||||
"followed_by" => true
|
||||
}
|
||||
}
|
||||
}
|
||||
] =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{user.id}/followers?with_relationships=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
{:ok, _, _} = User.follow(user, other_user)
|
||||
|
||||
assert [
|
||||
%{
|
||||
"id" => ^id,
|
||||
"pleroma" => %{
|
||||
"relationship" => %{
|
||||
"id" => ^id,
|
||||
"following" => true,
|
||||
"followed_by" => true
|
||||
}
|
||||
}
|
||||
}
|
||||
] =
|
||||
conn
|
||||
|> get("/api/v1/accounts/#{user.id}/followers?with_relationships=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "getting followers, hide_followers", %{user: user, conn: conn} do
|
||||
other_user = insert(:user, hide_followers: true)
|
||||
{:ok, _user, _other_user} = User.follow(user, other_user)
|
||||
|
|
@ -660,6 +738,24 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert id == to_string(other_user.id)
|
||||
end
|
||||
|
||||
test "following with relationship", %{conn: conn, user: user} do
|
||||
other_user = insert(:user)
|
||||
{:ok, user, other_user} = User.follow(user, other_user)
|
||||
|
||||
conn = get(conn, "/api/v1/accounts/#{user.id}/following?with_relationships=true")
|
||||
|
||||
id = other_user.id
|
||||
|
||||
assert [
|
||||
%{
|
||||
"id" => ^id,
|
||||
"pleroma" => %{
|
||||
"relationship" => %{"id" => ^id, "following" => true, "followed_by" => false}
|
||||
}
|
||||
}
|
||||
] = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "getting following, hide_follows, other user requesting" do
|
||||
user = insert(:user, hide_follows: true)
|
||||
other_user = insert(:user)
|
||||
|
|
@ -1007,7 +1103,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert %{"error" => "{\"email\":[\"Invalid email\"]}"} =
|
||||
json_response_and_validate_schema(conn, 400)
|
||||
|
||||
Pleroma.Config.put([User, :email_blacklist], [])
|
||||
clear_config([User, :email_blacklist], [])
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1565,7 +1661,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/mutes")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
|
|
@ -1573,7 +1668,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/mutes?limit=1")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
|
|
@ -1581,7 +1675,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/mutes?since_id=#{id1}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
|
|
@ -1589,7 +1682,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/mutes?since_id=#{id1}&max_id=#{id3}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
|
|
@ -1597,13 +1689,45 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/mutes?since_id=#{id1}&limit=1")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert [%{"id" => ^id2}] = result
|
||||
end
|
||||
|
||||
test "list of mutes with with_relationships parameter" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:mutes"])
|
||||
%{id: id1} = other_user1 = insert(:user)
|
||||
%{id: id2} = other_user2 = insert(:user)
|
||||
%{id: id3} = other_user3 = insert(:user)
|
||||
|
||||
{:ok, _, _} = User.follow(other_user1, user)
|
||||
{:ok, _, _} = User.follow(other_user2, user)
|
||||
{:ok, _, _} = User.follow(other_user3, user)
|
||||
|
||||
{:ok, _} = User.mute(user, other_user1)
|
||||
{:ok, _} = User.mute(user, other_user2)
|
||||
{:ok, _} = User.mute(user, other_user3)
|
||||
|
||||
assert [
|
||||
%{
|
||||
"id" => ^id1,
|
||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
||||
},
|
||||
%{
|
||||
"id" => ^id2,
|
||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
||||
},
|
||||
%{
|
||||
"id" => ^id3,
|
||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
||||
}
|
||||
] =
|
||||
conn
|
||||
|> get("/api/v1/mutes?with_relationships=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "getting a list of blocks" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:blocks"])
|
||||
%{id: id1} = other_user1 = insert(:user)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
assert result["pleroma"]["metadata"]["federation"]
|
||||
assert result["pleroma"]["metadata"]["fields_limits"]
|
||||
assert result["pleroma"]["vapid_public_key"]
|
||||
assert result["pleroma"]["stats"]["mau"] == 0
|
||||
|
||||
assert email == from_config_email
|
||||
assert thumbnail == from_config_thumbnail
|
||||
|
|
|
|||
|
|
@ -55,30 +55,39 @@ defmodule Pleroma.Web.MastodonAPI.ListControllerTest do
|
|||
test "adding users to a list" do
|
||||
%{user: user, conn: conn} = oauth_access(["write:lists"])
|
||||
other_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
{:ok, list} = Pleroma.List.create("name", user)
|
||||
|
||||
assert %{} ==
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/lists/#{list.id}/accounts", %{"account_ids" => [other_user.id]})
|
||||
|> post("/api/v1/lists/#{list.id}/accounts", %{
|
||||
"account_ids" => [other_user.id, third_user.id]
|
||||
})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
%Pleroma.List{following: following} = Pleroma.List.get(list.id, user)
|
||||
assert following == [other_user.follower_address]
|
||||
assert length(following) == 2
|
||||
assert other_user.follower_address in following
|
||||
assert third_user.follower_address in following
|
||||
end
|
||||
|
||||
test "removing users from a list, body params" do
|
||||
%{user: user, conn: conn} = oauth_access(["write:lists"])
|
||||
other_user = insert(:user)
|
||||
third_user = insert(:user)
|
||||
fourth_user = insert(:user)
|
||||
{:ok, list} = Pleroma.List.create("name", user)
|
||||
{:ok, list} = Pleroma.List.follow(list, other_user)
|
||||
{:ok, list} = Pleroma.List.follow(list, third_user)
|
||||
{:ok, list} = Pleroma.List.follow(list, fourth_user)
|
||||
|
||||
assert %{} ==
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/v1/lists/#{list.id}/accounts", %{"account_ids" => [other_user.id]})
|
||||
|> delete("/api/v1/lists/#{list.id}/accounts", %{
|
||||
"account_ids" => [other_user.id, fourth_user.id]
|
||||
})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
%Pleroma.List{following: following} = Pleroma.List.get(list.id, user)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do
|
|||
end
|
||||
|
||||
test "updates a scheduled activity" do
|
||||
Pleroma.Config.put([ScheduledActivity, :enabled], true)
|
||||
clear_config([ScheduledActivity, :enabled], true)
|
||||
%{user: user, conn: conn} = oauth_access(["write:statuses"])
|
||||
|
||||
scheduled_at = Timex.shift(NaiveDateTime.utc_now(), minutes: 60)
|
||||
|
|
@ -103,7 +103,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do
|
|||
end
|
||||
|
||||
test "deletes a scheduled activity" do
|
||||
Pleroma.Config.put([ScheduledActivity, :enabled], true)
|
||||
clear_config([ScheduledActivity, :enabled], true)
|
||||
%{user: user, conn: conn} = oauth_access(["write:statuses"])
|
||||
scheduled_at = Timex.shift(NaiveDateTime.utc_now(), minutes: 60)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
use Oban.Testing, repo: Pleroma.Repo
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Conversation.Participation
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
|
|
@ -29,7 +28,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
setup do: oauth_access(["write:statuses"])
|
||||
|
||||
test "posting a status does not increment reblog_count when relaying", %{conn: conn} do
|
||||
Config.put([:instance, :federating], true)
|
||||
clear_config([:instance, :federating], true)
|
||||
Config.get([:instance, :allow_relay], true)
|
||||
|
||||
response =
|
||||
|
|
@ -151,8 +150,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end
|
||||
|
||||
test "Get MRF reason when posting a status is rejected by one", %{conn: conn} do
|
||||
Config.put([:mrf_keyword, :reject], ["GNO"])
|
||||
Config.put([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.KeywordPolicy])
|
||||
clear_config([:mrf_keyword, :reject], ["GNO"])
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.KeywordPolicy])
|
||||
|
||||
assert %{"error" => "[KeywordPolicy] Matches with rejected keyword"} =
|
||||
conn
|
||||
|
|
@ -264,6 +263,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
fake_conn =
|
||||
conn
|
||||
|> assign(:user, refresh_record(conn.assigns.user))
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" =>
|
||||
|
|
@ -516,7 +516,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end)
|
||||
|
||||
assert NaiveDateTime.diff(NaiveDateTime.from_iso8601!(response["poll"]["expires_at"]), time) in 420..430
|
||||
refute response["poll"]["expred"]
|
||||
assert response["poll"]["expired"] == false
|
||||
|
||||
question = Object.get_by_id(response["poll"]["id"])
|
||||
|
||||
|
|
@ -592,6 +592,44 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
%{"error" => error} = json_response_and_validate_schema(conn, 422)
|
||||
assert error == "Expiration date is too far in the future"
|
||||
end
|
||||
|
||||
test "scheduled poll", %{conn: conn} do
|
||||
clear_config([ScheduledActivity, :enabled], true)
|
||||
|
||||
scheduled_at =
|
||||
NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(6), :millisecond)
|
||||
|> NaiveDateTime.to_iso8601()
|
||||
|> Kernel.<>("Z")
|
||||
|
||||
%{"id" => scheduled_id} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "very cool poll",
|
||||
"poll" => %{
|
||||
"options" => ~w(a b c),
|
||||
"expires_in" => 420
|
||||
},
|
||||
"scheduled_at" => scheduled_at
|
||||
})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert {:ok, %{id: activity_id}} =
|
||||
perform_job(Pleroma.Workers.ScheduledActivityWorker, %{
|
||||
activity_id: scheduled_id
|
||||
})
|
||||
|
||||
assert Repo.all(Oban.Job) == []
|
||||
|
||||
object =
|
||||
Activity
|
||||
|> Repo.get(activity_id)
|
||||
|> Object.normalize()
|
||||
|
||||
assert object.data["content"] == "very cool poll"
|
||||
assert object.data["type"] == "Question"
|
||||
assert length(object.data["oneOf"]) == 3
|
||||
end
|
||||
end
|
||||
|
||||
test "get a status" do
|
||||
|
|
@ -1204,7 +1242,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
describe "cards" do
|
||||
setup do
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
clear_config([:rich_media, :enabled], true)
|
||||
|
||||
oauth_access(["read:statuses"])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -90,6 +90,65 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
}
|
||||
] = result
|
||||
end
|
||||
|
||||
test "filtering", %{conn: conn, user: user} do
|
||||
local_user = insert(:user)
|
||||
{:ok, user, local_user} = User.follow(user, local_user)
|
||||
{:ok, local_activity} = CommonAPI.post(local_user, %{status: "Status"})
|
||||
with_media = create_with_media_activity(local_user)
|
||||
|
||||
remote_user = insert(:user, local: false)
|
||||
{:ok, _user, remote_user} = User.follow(user, remote_user)
|
||||
remote_activity = create_remote_activity(remote_user)
|
||||
|
||||
without_filter_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/home")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert local_activity.id in without_filter_ids
|
||||
assert remote_activity.id in without_filter_ids
|
||||
assert with_media.id in without_filter_ids
|
||||
|
||||
only_local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/home?local=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert local_activity.id in only_local_ids
|
||||
refute remote_activity.id in only_local_ids
|
||||
assert with_media.id in only_local_ids
|
||||
|
||||
only_local_media_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/home?local=true&only_media=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute local_activity.id in only_local_media_ids
|
||||
refute remote_activity.id in only_local_media_ids
|
||||
assert with_media.id in only_local_media_ids
|
||||
|
||||
remote_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/home?remote=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute local_activity.id in remote_ids
|
||||
assert remote_activity.id in remote_ids
|
||||
refute with_media.id in remote_ids
|
||||
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/home?remote=true&only_media=true")
|
||||
|> json_response_and_validate_schema(200) == []
|
||||
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/home?remote=true&local=true")
|
||||
|> json_response_and_validate_schema(200) == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "public" do
|
||||
|
|
@ -98,27 +157,80 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "test"})
|
||||
with_media = create_with_media_activity(user)
|
||||
|
||||
_activity = insert(:note_activity, local: false)
|
||||
remote = insert(:note_activity, local: false)
|
||||
|
||||
conn = get(conn, "/api/v1/timelines/public?local=False")
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/public?local=False")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> length == 3
|
||||
|
||||
assert length(json_response_and_validate_schema(conn, :ok)) == 2
|
||||
local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?local=True")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
conn = get(build_conn(), "/api/v1/timelines/public?local=True")
|
||||
assert activity.id in local_ids
|
||||
assert with_media.id in local_ids
|
||||
refute remote.id in local_ids
|
||||
|
||||
assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
|
||||
local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?local=True")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
conn = get(build_conn(), "/api/v1/timelines/public?local=1")
|
||||
assert activity.id in local_ids
|
||||
assert with_media.id in local_ids
|
||||
refute remote.id in local_ids
|
||||
|
||||
assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok)
|
||||
local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?local=True&only_media=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute activity.id in local_ids
|
||||
assert with_media.id in local_ids
|
||||
refute remote.id in local_ids
|
||||
|
||||
local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?local=1")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert activity.id in local_ids
|
||||
assert with_media.id in local_ids
|
||||
refute remote.id in local_ids
|
||||
|
||||
remote_id = remote.id
|
||||
|
||||
assert [%{"id" => ^remote_id}] =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?remote=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
with_media_id = with_media.id
|
||||
|
||||
assert [%{"id" => ^with_media_id}] =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?only_media=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/public?remote=true&only_media=true")
|
||||
|> json_response_and_validate_schema(:ok) == []
|
||||
|
||||
# does not contain repeats
|
||||
{:ok, _} = CommonAPI.repeat(activity.id, user)
|
||||
|
||||
conn = get(build_conn(), "/api/v1/timelines/public?local=true")
|
||||
|
||||
assert [_] = json_response_and_validate_schema(conn, :ok)
|
||||
assert [_, _] =
|
||||
conn
|
||||
|> get("/api/v1/timelines/public?local=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
end
|
||||
|
||||
test "the public timeline includes only public statuses for an authenticated user" do
|
||||
|
|
@ -544,6 +656,77 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
}
|
||||
] = result
|
||||
end
|
||||
|
||||
test "filtering", %{user: user, conn: conn} do
|
||||
{:ok, list} = Pleroma.List.create("name", user)
|
||||
|
||||
local_user = insert(:user)
|
||||
{:ok, local_activity} = CommonAPI.post(local_user, %{status: "Marisa is stupid."})
|
||||
with_media = create_with_media_activity(local_user)
|
||||
{:ok, list} = Pleroma.List.follow(list, local_user)
|
||||
|
||||
remote_user = insert(:user, local: false)
|
||||
remote_activity = create_remote_activity(remote_user)
|
||||
{:ok, list} = Pleroma.List.follow(list, remote_user)
|
||||
|
||||
all_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert local_activity.id in all_ids
|
||||
assert with_media.id in all_ids
|
||||
assert remote_activity.id in all_ids
|
||||
|
||||
only_local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}?local=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert local_activity.id in only_local_ids
|
||||
assert with_media.id in only_local_ids
|
||||
refute remote_activity.id in only_local_ids
|
||||
|
||||
only_local_media_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}?local=true&only_media=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute local_activity.id in only_local_media_ids
|
||||
assert with_media.id in only_local_media_ids
|
||||
refute remote_activity.id in only_local_media_ids
|
||||
|
||||
remote_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}?remote=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute local_activity.id in remote_ids
|
||||
refute with_media.id in remote_ids
|
||||
assert remote_activity.id in remote_ids
|
||||
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}?remote=true&only_media=true")
|
||||
|> json_response_and_validate_schema(200) == []
|
||||
|
||||
only_media_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}?only_media=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute local_activity.id in only_media_ids
|
||||
assert with_media.id in only_media_ids
|
||||
refute remote_activity.id in only_media_ids
|
||||
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/list/#{list.id}?only_media=true&local=true&remote=true")
|
||||
|> json_response_and_validate_schema(200) == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "hashtag" do
|
||||
|
|
@ -554,19 +737,85 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
following = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(following, %{status: "test #2hu"})
|
||||
with_media = create_with_media_activity(following)
|
||||
|
||||
nconn = get(conn, "/api/v1/timelines/tag/2hu")
|
||||
remote = insert(:user, local: false)
|
||||
remote_activity = create_remote_activity(remote)
|
||||
|
||||
assert [%{"id" => id}] = json_response_and_validate_schema(nconn, :ok)
|
||||
all_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2hu")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert id == to_string(activity.id)
|
||||
assert activity.id in all_ids
|
||||
assert with_media.id in all_ids
|
||||
assert remote_activity.id in all_ids
|
||||
|
||||
# works for different capitalization too
|
||||
nconn = get(conn, "/api/v1/timelines/tag/2HU")
|
||||
all_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2HU")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert [%{"id" => id}] = json_response_and_validate_schema(nconn, :ok)
|
||||
assert activity.id in all_ids
|
||||
assert with_media.id in all_ids
|
||||
assert remote_activity.id in all_ids
|
||||
|
||||
assert id == to_string(activity.id)
|
||||
local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2hu?local=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
assert activity.id in local_ids
|
||||
assert with_media.id in local_ids
|
||||
refute remote_activity.id in local_ids
|
||||
|
||||
remote_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2hu?remote=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute activity.id in remote_ids
|
||||
refute with_media.id in remote_ids
|
||||
assert remote_activity.id in remote_ids
|
||||
|
||||
media_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2hu?only_media=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute activity.id in media_ids
|
||||
assert with_media.id in media_ids
|
||||
refute remote_activity.id in media_ids
|
||||
|
||||
media_local_ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2hu?only_media=true&local=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute activity.id in media_local_ids
|
||||
assert with_media.id in media_local_ids
|
||||
refute remote_activity.id in media_local_ids
|
||||
|
||||
ids =
|
||||
conn
|
||||
|> get("/api/v1/timelines/tag/2hu?only_media=true&local=true&remote=true")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|> Enum.map(& &1["id"])
|
||||
|
||||
refute activity.id in ids
|
||||
refute with_media.id in ids
|
||||
refute remote_activity.id in ids
|
||||
|
||||
assert conn
|
||||
|> get("/api/v1/timelines/tag/2hu?only_media=true&remote=true")
|
||||
|> json_response_and_validate_schema(:ok) == []
|
||||
end
|
||||
|
||||
test "multi-hashtag timeline", %{conn: conn} do
|
||||
|
|
@ -726,4 +975,37 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
ensure_authenticated_access(base_uri)
|
||||
end
|
||||
end
|
||||
|
||||
defp create_remote_activity(user) do
|
||||
obj =
|
||||
insert(:note, %{
|
||||
data: %{
|
||||
"to" => [
|
||||
"https://www.w3.org/ns/activitystreams#Public",
|
||||
User.ap_followers(user)
|
||||
]
|
||||
},
|
||||
user: user
|
||||
})
|
||||
|
||||
insert(:note_activity, %{
|
||||
note: obj,
|
||||
recipients: [
|
||||
"https://www.w3.org/ns/activitystreams#Public",
|
||||
User.ap_followers(user)
|
||||
],
|
||||
user: user,
|
||||
local: false
|
||||
})
|
||||
end
|
||||
|
||||
defp create_with_media_activity(user) do
|
||||
obj = insert(:attachment_note, user: user)
|
||||
|
||||
insert(:note_activity, %{
|
||||
note: obj,
|
||||
recipients: ["https://www.w3.org/ns/activitystreams#Public", User.ap_followers(user)],
|
||||
user: user
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.MastoFEControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
@ -55,7 +54,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEControllerTest do
|
|||
conn: conn,
|
||||
path: path
|
||||
} do
|
||||
Config.put([:instance, :public], false)
|
||||
clear_config([:instance, :public], false)
|
||||
|
||||
conn = get(conn, path)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserRelationship
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -74,6 +73,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
},
|
||||
fields: []
|
||||
},
|
||||
fqn: "shp@shitposter.club",
|
||||
pleroma: %{
|
||||
ap_id: user.ap_id,
|
||||
also_known_as: ["https://shitposter.zone/users/shp"],
|
||||
|
|
@ -173,6 +173,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
},
|
||||
fields: []
|
||||
},
|
||||
fqn: "shp@shitposter.club",
|
||||
pleroma: %{
|
||||
ap_id: user.ap_id,
|
||||
also_known_as: [],
|
||||
|
|
@ -556,7 +557,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
)
|
||||
|
||||
with media_preview_enabled <- [false, true] do
|
||||
Config.put([:media_preview_proxy, :enabled], media_preview_enabled)
|
||||
clear_config([:media_preview_proxy, :enabled], media_preview_enabled)
|
||||
|
||||
AccountView.render("show.json", %{user: user, skip_visibility_check: true})
|
||||
|> Enum.all?(fn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue