changes =
%User{}
|> cast(params, [:bio, :name, :ap_id, :nickname, :info, :avatar])
- |> validate_required([:name, :ap_id, :nickname])
+ |> validate_required([:name, :ap_id])
|> unique_constraint(:nickname)
|> validate_format(:nickname, @email_regex)
|> validate_length(:bio, max: 5000)
"locked" => locked
},
avatar: avatar,
- nickname: "#{data["preferredUsername"]}@#{URI.parse(data["id"]).host}",
name: data["name"],
follower_address: data["followers"],
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}
end