Deprecate Pleroma.Web.base_url/0
Use Pleroma.Web.Endpoint.url/0 directly instead. Reduces compiler cycles.
This commit is contained in:
parent
2e682788a3
commit
51a9f97e87
43 changed files with 93 additions and 96 deletions
|
|
@ -151,7 +151,7 @@ defmodule Pleroma.UserTest do
|
|||
test "ap_id returns the activity pub id for the user" do
|
||||
user = UserBuilder.build()
|
||||
|
||||
expected_ap_id = "#{Pleroma.Web.base_url()}/users/#{user.nickname}"
|
||||
expected_ap_id = "#{Pleroma.Web.Endpoint.url()}/users/#{user.nickname}"
|
||||
|
||||
assert expected_ap_id == User.ap_id(user)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||
|
||||
defp build_local_message do
|
||||
%{
|
||||
"actor" => "#{Pleroma.Web.base_url()}/users/alice",
|
||||
"actor" => "#{Pleroma.Web.Endpoint.url()}/users/alice",
|
||||
"to" => [],
|
||||
"cc" => []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
},
|
||||
%{
|
||||
"rel" => "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template" => "#{Pleroma.Web.base_url()}/ostatus_subscribe?acct={uri}"
|
||||
"template" => "#{Pleroma.Web.Endpoint.url()}/ostatus_subscribe?acct={uri}"
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.AdminAPI.OAuthAppControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Web
|
||||
alias Pleroma.Web.Endpoint
|
||||
|
||||
setup do
|
||||
admin = insert(:user, is_admin: true)
|
||||
|
|
@ -36,7 +36,7 @@ defmodule Pleroma.Web.AdminAPI.OAuthAppControllerTest do
|
|||
end
|
||||
|
||||
test "success", %{conn: conn} do
|
||||
base_url = Web.base_url()
|
||||
base_url = Endpoint.url()
|
||||
app_name = "Trusted app"
|
||||
|
||||
response =
|
||||
|
|
@ -58,7 +58,7 @@ defmodule Pleroma.Web.AdminAPI.OAuthAppControllerTest do
|
|||
end
|
||||
|
||||
test "with trusted", %{conn: conn} do
|
||||
base_url = Web.base_url()
|
||||
base_url = Endpoint.url()
|
||||
app_name = "Trusted app"
|
||||
|
||||
response =
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web
|
||||
alias Pleroma.Web.ActivityPub.Relay
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.MediaProxy
|
||||
|
||||
setup_all do
|
||||
|
|
@ -403,7 +403,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
|
|||
end
|
||||
|
||||
test "pagination works correctly with service users", %{conn: conn} do
|
||||
service1 = User.get_or_create_service_actor_by_ap_id(Web.base_url() <> "/meido", "meido")
|
||||
service1 = User.get_or_create_service_actor_by_ap_id(Endpoint.url() <> "/meido", "meido")
|
||||
|
||||
insert_list(25, :user)
|
||||
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
{:ok, activity} = CommonAPI.post(user, %{status: "hey :blank:"})
|
||||
|
||||
assert %{"blank" => url} = Object.normalize(activity).data["emoji"]
|
||||
assert url == "#{Pleroma.Web.base_url()}/emoji/blank.png"
|
||||
assert url == "#{Pleroma.Web.Endpoint.url()}/emoji/blank.png"
|
||||
end
|
||||
|
||||
test "deactivated users can't post" do
|
||||
|
|
|
|||
|
|
@ -127,10 +127,10 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
"These are public toots tagged with #pleromaart. You can interact with them if you have an account anywhere in the fediverse."
|
||||
|
||||
assert xpath(xml, ~x"//channel/link/text()") ==
|
||||
'#{Pleroma.Web.base_url()}/tags/pleromaart.rss'
|
||||
'#{Pleroma.Web.Endpoint.url()}/tags/pleromaart.rss'
|
||||
|
||||
assert xpath(xml, ~x"//channel/webfeeds:logo/text()") ==
|
||||
'#{Pleroma.Web.base_url()}/static/logo.svg'
|
||||
'#{Pleroma.Web.Endpoint.url()}/static/logo.svg'
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/title/text()"l) == [
|
||||
'42 This is :moominmamm...',
|
||||
|
|
|
|||
|
|
@ -217,7 +217,9 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
|||
|> get("/users/#{user.nickname}")
|
||||
|
||||
assert conn.status == 302
|
||||
assert redirected_to(conn) == "#{Pleroma.Web.base_url()}/users/#{user.nickname}/feed.atom"
|
||||
|
||||
assert redirected_to(conn) ==
|
||||
"#{Pleroma.Web.Endpoint.url()}/users/#{user.nickname}/feed.atom"
|
||||
end
|
||||
|
||||
test "with non-html / non-json format, it returns error when user is not found", %{conn: conn} do
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
assert result = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
email = Pleroma.Config.get([:instance, :email])
|
||||
thumbnail = Pleroma.Web.base_url() <> Pleroma.Config.get([:instance, :instance_thumbnail])
|
||||
background = Pleroma.Web.base_url() <> Pleroma.Config.get([:instance, :background_image])
|
||||
thumbnail = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :instance_thumbnail])
|
||||
background = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :background_image])
|
||||
|
||||
# Note: not checking for "max_toot_chars" since it's optional
|
||||
assert %{
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Web
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Endpoint
|
||||
import Pleroma.Factory
|
||||
import ExUnit.CaptureLog
|
||||
import Tesla.Mock
|
||||
|
|
@ -61,7 +61,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
assert account["id"] == to_string(user_three.id)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "private", "url" => "#{Web.base_url()}/tag/private"}
|
||||
%{"name" => "private", "url" => "#{Endpoint.url()}/tag/private"}
|
||||
]
|
||||
|
||||
[status] = results["statuses"]
|
||||
|
|
@ -72,7 +72,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "天子", "url" => "#{Web.base_url()}/tag/天子"}
|
||||
%{"name" => "天子", "url" => "#{Endpoint.url()}/tag/天子"}
|
||||
]
|
||||
|
||||
[status] = results["statuses"]
|
||||
|
|
@ -87,8 +87,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "explicit", "url" => "#{Web.base_url()}/tag/explicit"},
|
||||
%{"name" => "hashtags", "url" => "#{Web.base_url()}/tag/hashtags"}
|
||||
%{"name" => "explicit", "url" => "#{Endpoint.url()}/tag/explicit"},
|
||||
%{"name" => "hashtags", "url" => "#{Endpoint.url()}/tag/hashtags"}
|
||||
]
|
||||
|
||||
results =
|
||||
|
|
@ -97,9 +97,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "john", "url" => "#{Web.base_url()}/tag/john"},
|
||||
%{"name" => "doe", "url" => "#{Web.base_url()}/tag/doe"},
|
||||
%{"name" => "JohnDoe", "url" => "#{Web.base_url()}/tag/JohnDoe"}
|
||||
%{"name" => "john", "url" => "#{Endpoint.url()}/tag/john"},
|
||||
%{"name" => "doe", "url" => "#{Endpoint.url()}/tag/doe"},
|
||||
%{"name" => "JohnDoe", "url" => "#{Endpoint.url()}/tag/JohnDoe"}
|
||||
]
|
||||
|
||||
results =
|
||||
|
|
@ -108,9 +108,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "accident", "url" => "#{Web.base_url()}/tag/accident"},
|
||||
%{"name" => "prone", "url" => "#{Web.base_url()}/tag/prone"},
|
||||
%{"name" => "AccidentProne", "url" => "#{Web.base_url()}/tag/AccidentProne"}
|
||||
%{"name" => "accident", "url" => "#{Endpoint.url()}/tag/accident"},
|
||||
%{"name" => "prone", "url" => "#{Endpoint.url()}/tag/prone"},
|
||||
%{"name" => "AccidentProne", "url" => "#{Endpoint.url()}/tag/AccidentProne"}
|
||||
]
|
||||
|
||||
results =
|
||||
|
|
@ -119,7 +119,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "shpuld", "url" => "#{Web.base_url()}/tag/shpuld"}
|
||||
%{"name" => "shpuld", "url" => "#{Endpoint.url()}/tag/shpuld"}
|
||||
]
|
||||
|
||||
results =
|
||||
|
|
@ -136,18 +136,18 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "nascar", "url" => "#{Web.base_url()}/tag/nascar"},
|
||||
%{"name" => "ban", "url" => "#{Web.base_url()}/tag/ban"},
|
||||
%{"name" => "display", "url" => "#{Web.base_url()}/tag/display"},
|
||||
%{"name" => "confederate", "url" => "#{Web.base_url()}/tag/confederate"},
|
||||
%{"name" => "flag", "url" => "#{Web.base_url()}/tag/flag"},
|
||||
%{"name" => "all", "url" => "#{Web.base_url()}/tag/all"},
|
||||
%{"name" => "events", "url" => "#{Web.base_url()}/tag/events"},
|
||||
%{"name" => "properties", "url" => "#{Web.base_url()}/tag/properties"},
|
||||
%{"name" => "nascar", "url" => "#{Endpoint.url()}/tag/nascar"},
|
||||
%{"name" => "ban", "url" => "#{Endpoint.url()}/tag/ban"},
|
||||
%{"name" => "display", "url" => "#{Endpoint.url()}/tag/display"},
|
||||
%{"name" => "confederate", "url" => "#{Endpoint.url()}/tag/confederate"},
|
||||
%{"name" => "flag", "url" => "#{Endpoint.url()}/tag/flag"},
|
||||
%{"name" => "all", "url" => "#{Endpoint.url()}/tag/all"},
|
||||
%{"name" => "events", "url" => "#{Endpoint.url()}/tag/events"},
|
||||
%{"name" => "properties", "url" => "#{Endpoint.url()}/tag/properties"},
|
||||
%{
|
||||
"name" => "NascarBanDisplayConfederateFlagAllEventsProperties",
|
||||
"url" =>
|
||||
"#{Web.base_url()}/tag/NascarBanDisplayConfederateFlagAllEventsProperties"
|
||||
"#{Endpoint.url()}/tag/NascarBanDisplayConfederateFlagAllEventsProperties"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
|
@ -163,8 +163,8 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "text", "url" => "#{Web.base_url()}/tag/text"},
|
||||
%{"name" => "with", "url" => "#{Web.base_url()}/tag/with"}
|
||||
%{"name" => "text", "url" => "#{Endpoint.url()}/tag/text"},
|
||||
%{"name" => "with", "url" => "#{Endpoint.url()}/tag/with"}
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -562,12 +562,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
AccountView.render("show.json", %{user: user, skip_visibility_check: true})
|
||||
|> Enum.all?(fn
|
||||
{key, url} when key in [:avatar, :avatar_static, :header, :header_static] ->
|
||||
String.starts_with?(url, Pleroma.Web.base_url())
|
||||
String.starts_with?(url, Pleroma.Web.Endpoint.url())
|
||||
|
||||
{:emojis, emojis} ->
|
||||
Enum.all?(emojis, fn %{url: url, static_url: static_url} ->
|
||||
String.starts_with?(url, Pleroma.Web.base_url()) &&
|
||||
String.starts_with?(static_url, Pleroma.Web.base_url())
|
||||
String.starts_with?(url, Pleroma.Web.Endpoint.url()) &&
|
||||
String.starts_with?(static_url, Pleroma.Web.Endpoint.url())
|
||||
end)
|
||||
|
||||
_ ->
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ defmodule Pleroma.Web.MediaProxyTest do
|
|||
|
||||
assert String.starts_with?(
|
||||
encoded,
|
||||
Config.get([:media_proxy, :base_url], Pleroma.Web.base_url())
|
||||
Config.get([:media_proxy, :base_url], Pleroma.Web.Endpoint.url())
|
||||
)
|
||||
|
||||
assert String.ends_with?(encoded, "/logo.png")
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
|> response(200)
|
||||
|
||||
assert resp =~
|
||||
"<meta content=\"#{Pleroma.Web.base_url()}/notice/#{note_activity.id}\" property=\"og:url\">"
|
||||
"<meta content=\"#{Pleroma.Web.Endpoint.url()}/notice/#{note_activity.id}\" property=\"og:url\">"
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
|
|||
|
||||
assert response.resp_body ==
|
||||
~s(<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="#{
|
||||
Pleroma.Web.base_url()
|
||||
Pleroma.Web.Endpoint.url()
|
||||
}/.well-known/webfinger?resource={uri}" type="application/xrd+xml" /></XRD>)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ defmodule Pleroma.Web.WebFingerTest do
|
|||
test "returns a link to the xml lrdd" do
|
||||
host_info = WebFinger.host_meta()
|
||||
|
||||
assert String.contains?(host_info, Pleroma.Web.base_url())
|
||||
assert String.contains?(host_info, Pleroma.Web.Endpoint.url())
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue