Commit 1c90f883 authored by kaniini's avatar kaniini
Browse files

user: remote actors can have no nickname if they are virtual services

parent 7bed350a
...@@ -77,7 +77,7 @@ def remote_user_creation(params) do ...@@ -77,7 +77,7 @@ def remote_user_creation(params) do
changes = changes =
%User{} %User{}
|> cast(params, [:bio, :name, :ap_id, :nickname, :info, :avatar]) |> cast(params, [:bio, :name, :ap_id, :nickname, :info, :avatar])
|> validate_required([:name, :ap_id, :nickname]) |> validate_required([:name, :ap_id])
|> unique_constraint(:nickname) |> unique_constraint(:nickname)
|> validate_format(:nickname, @email_regex) |> validate_format(:nickname, @email_regex)
|> validate_length(:bio, max: 5000) |> validate_length(:bio, max: 5000)
......
...@@ -554,12 +554,19 @@ def user_data_from_user_object(data) do ...@@ -554,12 +554,19 @@ def user_data_from_user_object(data) do
"locked" => locked "locked" => locked
}, },
avatar: avatar, avatar: avatar,
nickname: "#{data["preferredUsername"]}@#{URI.parse(data["id"]).host}",
name: data["name"], name: data["name"],
follower_address: data["followers"], follower_address: data["followers"],
bio: data["summary"] bio: data["summary"]
} }
# nickname can be nil because of virtual actors
user_data =
if data["preferredUsername"] do
Map.put(user_data, :nickname, "#{data["preferredUsername"]}@#{URI.parse(data["id"]).host}")
else
Map.put(user_data, :nickname, nil)
end
{:ok, user_data} {:ok, user_data}
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment