user view: add AP C2S oauth endpoints to local user profiles
This commit is contained in:
parent
99f955cd9e
commit
90facd3598
@ -15,6 +15,20 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
|
def render("endpoints.json", %{user: %{local: true} = _user}) do
|
||||||
|
%{
|
||||||
|
"oauthAuthorizationEndpoint" => "#{Pleroma.Web.Endpoint.url()}/oauth/authorize",
|
||||||
|
"oauthTokenEndpoint" => "#{Pleroma.Web.Endpoint.url()}/oauth/token"
|
||||||
|
}
|
||||||
|
|> Map.merge(render("endpoints.json", nil))
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
{:ok, user} = WebFinger.ensure_keys_present(user)
|
{:ok, user} = WebFinger.ensure_keys_present(user)
|
||||||
@ -22,6 +36,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
public_key = :public_key.pem_entry_encode(:SubjectPublicKeyInfo, public_key)
|
public_key = :public_key.pem_entry_encode(:SubjectPublicKeyInfo, public_key)
|
||||||
public_key = :public_key.pem_encode([public_key])
|
public_key = :public_key.pem_encode([public_key])
|
||||||
|
|
||||||
|
endpoints = render("endpoints.json", %{user: user})
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => user.ap_id,
|
"id" => user.ap_id,
|
||||||
"type" => "Application",
|
"type" => "Application",
|
||||||
@ -37,9 +53,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
"owner" => user.ap_id,
|
"owner" => user.ap_id,
|
||||||
"publicKeyPem" => public_key
|
"publicKeyPem" => public_key
|
||||||
},
|
},
|
||||||
"endpoints" => %{
|
"endpoints" => endpoints
|
||||||
"sharedInbox" => "#{Pleroma.Web.Endpoint.url()}/inbox"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
@ -50,6 +64,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
public_key = :public_key.pem_entry_encode(:SubjectPublicKeyInfo, public_key)
|
public_key = :public_key.pem_entry_encode(:SubjectPublicKeyInfo, public_key)
|
||||||
public_key = :public_key.pem_encode([public_key])
|
public_key = :public_key.pem_encode([public_key])
|
||||||
|
|
||||||
|
endpoints = render("endpoints.json", %{user: user})
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"id" => user.ap_id,
|
"id" => user.ap_id,
|
||||||
"type" => "Person",
|
"type" => "Person",
|
||||||
@ -67,9 +83,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
"owner" => user.ap_id,
|
"owner" => user.ap_id,
|
||||||
"publicKeyPem" => public_key
|
"publicKeyPem" => public_key
|
||||||
},
|
},
|
||||||
"endpoints" => %{
|
"endpoints" => endpoints,
|
||||||
"sharedInbox" => "#{Pleroma.Web.Endpoint.url()}/inbox"
|
|
||||||
},
|
|
||||||
"icon" => %{
|
"icon" => %{
|
||||||
"type" => "Image",
|
"type" => "Image",
|
||||||
"url" => User.avatar_url(user)
|
"url" => User.avatar_url(user)
|
||||||
|
Loading…
Reference in New Issue
Block a user