mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-11-05 00:19:44 +00:00
user: support creating an actor which represents the instance itself
This commit is contained in:
parent
d7368ea272
commit
4807a52284
1 changed files with 16 additions and 0 deletions
|
@ -637,6 +637,22 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_or_create_instance_user do
|
||||||
|
if user = get_by_ap_id(Pleroma.Web.Endpoint.url()) do
|
||||||
|
user
|
||||||
|
else
|
||||||
|
changes =
|
||||||
|
%User{}
|
||||||
|
|> cast(%{}, [:ap_id, :nickname, :local])
|
||||||
|
|> put_change(:ap_id, Pleroma.Web.Endpoint.url())
|
||||||
|
|> put_change(:nickname, nil)
|
||||||
|
|> put_change(:local, true)
|
||||||
|
|
||||||
|
{:ok, user} = Repo.insert(changes)
|
||||||
|
user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# AP style
|
# AP style
|
||||||
def public_key_from_info(%{
|
def public_key_from_info(%{
|
||||||
"source_data" => %{"publicKey" => %{"publicKeyPem" => public_key_pem}}
|
"source_data" => %{"publicKey" => %{"publicKeyPem" => public_key_pem}}
|
||||||
|
|
Loading…
Reference in a new issue