aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex9
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex4
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index d030c7314..0adea42ec 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -82,6 +82,7 @@ defmodule Pleroma.User do
field(:password, :string, virtual: true)
field(:password_confirmation, :string, virtual: true)
field(:keys, :string)
+ field(:public_key, :string)
field(:ap_id, :string)
field(:avatar, :map)
field(:local, :boolean, default: true)
@@ -366,6 +367,7 @@ defmodule Pleroma.User do
:name,
:ap_id,
:nickname,
+ :public_key,
:avatar,
:ap_enabled,
:source_data,
@@ -407,6 +409,7 @@ defmodule Pleroma.User do
:bio,
:name,
:avatar,
+ :public_key,
:locked,
:no_rich_text,
:default_scope,
@@ -503,6 +506,7 @@ defmodule Pleroma.User do
:name,
:follower_address,
:following_address,
+ :public_key,
:avatar,
:last_refreshed_at,
:ap_enabled,
@@ -1616,8 +1620,7 @@ defmodule Pleroma.User do
|> set_cache()
end
- # AP style
- def public_key(%{source_data: %{"publicKey" => %{"publicKeyPem" => public_key_pem}}}) do
+ def public_key(%{public_key: public_key_pem}) when is_binary(public_key_pem) do
key =
public_key_pem
|> :public_key.pem_decode()
@@ -1627,7 +1630,7 @@ defmodule Pleroma.User do
{:ok, key}
end
- def public_key(_), do: {:error, "not found key"}
+ def public_key(_), do: {:error, "key not found"}
def get_public_key_for_ap_id(ap_id) do
with {:ok, %User{} = user} <- get_or_fetch_by_ap_id(ap_id),
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 19286fd01..0e4a9d842 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -1432,6 +1432,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
discoverable = data["discoverable"] || false
invisible = data["invisible"] || false
actor_type = data["type"] || "Person"
+ public_key = data["publicKey"]["publicKeyPem"]
user_data = %{
ap_id: data["id"],
@@ -1449,7 +1450,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
following_address: data["following"],
bio: data["summary"],
actor_type: actor_type,
- also_known_as: Map.get(data, "alsoKnownAs", [])
+ also_known_as: Map.get(data, "alsoKnownAs", []),
+ public_key: public_key
}
# nickname can be nil because of virtual actors