activitypub: user view: use route helpers instead of hardcoded URIs
This commit is contained in:
parent
29e946ace4
commit
9bd6ed975e
|
@ -12,23 +12,21 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
|
alias Pleroma.Web.Router.Helpers
|
||||||
|
alias Pleroma.Web.Endpoint
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
def render("endpoints.json", %{user: %User{local: true} = _user}) do
|
def render("endpoints.json", %{user: %User{nickname: _nickname, local: true} = _user}) do
|
||||||
%{
|
%{
|
||||||
"oauthAuthorizationEndpoint" => "#{Pleroma.Web.Endpoint.url()}/oauth/authorize",
|
"oauthAuthorizationEndpoint" => Helpers.o_auth_url(Endpoint, :authorize),
|
||||||
"oauthRegistrationEndpoint" => "#{Pleroma.Web.Endpoint.url()}/api/v1/apps",
|
"oauthRegistrationEndpoint" => Helpers.mastodon_api_url(Endpoint, :create_app),
|
||||||
"oauthTokenEndpoint" => "#{Pleroma.Web.Endpoint.url()}/oauth/token"
|
"oauthTokenEndpoint" => Helpers.o_auth_url(Endpoint, :token_exchange),
|
||||||
|
"sharedInbox" => Helpers.activity_pub_url(Endpoint, :inbox)
|
||||||
}
|
}
|
||||||
|> Map.merge(render("endpoints.json", %{user: nil}))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("endpoints.json", _) do
|
def render("endpoints.json", _), do: %{}
|
||||||
%{
|
|
||||||
"sharedInbox" => "#{Pleroma.Web.Endpoint.url()}/inbox"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# the instance itself is not a Person, but instead an Application
|
# the instance itself is not a Person, but instead an Application
|
||||||
def render("user.json", %{user: %{nickname: nil} = user}) do
|
def render("user.json", %{user: %{nickname: nil} = user}) do
|
||||||
|
|
|
@ -468,8 +468,8 @@ defmodule Pleroma.Web.Router do
|
||||||
|
|
||||||
scope "/", Pleroma.Web.ActivityPub do
|
scope "/", Pleroma.Web.ActivityPub do
|
||||||
pipe_through(:activitypub)
|
pipe_through(:activitypub)
|
||||||
post("/users/:nickname/inbox", ActivityPubController, :inbox)
|
|
||||||
post("/inbox", ActivityPubController, :inbox)
|
post("/inbox", ActivityPubController, :inbox)
|
||||||
|
post("/users/:nickname/inbox", ActivityPubController, :inbox)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/.well-known", Pleroma.Web do
|
scope "/.well-known", Pleroma.Web do
|
||||||
|
|
Loading…
Reference in New Issue