projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'feature/instance-fetch-actor' into 'develop'
[akkoma]
/
lib
/
pleroma
/
user.ex
diff --git
a/lib/pleroma/user.ex
b/lib/pleroma/user.ex
index ffba3f3903912e343b61ccdef045225196b02600..c91fbb68a24b52fbf03f474b66ece5d82e8837dc 100644
(file)
--- a/
lib/pleroma/user.ex
+++ b/
lib/pleroma/user.ex
@@
-1157,19
+1157,18
@@
defmodule Pleroma.User do
end
end
end
end
- def get_or_create_instance_user do
- relay_uri = "#{Pleroma.Web.Endpoint.url()}/relay"
-
- if user = get_cached_by_ap_id(relay_uri) do
+ @doc "Creates an internal service actor by URI if missing. Optionally takes nickname for addressing."
+ def get_or_create_service_actor_by_ap_id(uri, nickname \\ nil) do
+ if user = get_cached_by_ap_id(uri) do
user
else
changes =
%User{info: %User.Info{}}
|> cast(%{}, [:ap_id, :nickname, :local])
user
else
changes =
%User{info: %User.Info{}}
|> cast(%{}, [:ap_id, :nickname, :local])
- |> put_change(:ap_id,
relay_
uri)
- |> put_change(:nickname, ni
l
)
+ |> put_change(:ap_id, uri)
+ |> put_change(:nickname, ni
ckname
)
|> put_change(:local, true)
|> put_change(:local, true)
- |> put_change(:follower_address,
relay_
uri <> "/followers")
+ |> put_change(:follower_address, uri <> "/followers")
{:ok, user} = Repo.insert(changes)
user
{:ok, user} = Repo.insert(changes)
user
@@
-1411,4
+1410,8
@@
defmodule Pleroma.User do
end
defp put_password_hash(changeset), do: changeset
end
defp put_password_hash(changeset), do: changeset
+
+ def is_internal_user?(%User{nickname: nil}), do: true
+ def is_internal_user?(%User{local: true, nickname: "internal." <> _}), do: true
+ def is_internal_user?(_), do: false
end
end