From: William Pitcock Date: Mon, 6 Aug 2018 06:50:18 +0000 (+0000) Subject: user: remote actors can have no nickname if they are virtual services X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=1c90f88393c10198f34aa3a19f09169bcddeeac3;p=akkoma user: remote actors can have no nickname if they are virtual services --- diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 640c34aec..82a2a7833 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -77,7 +77,7 @@ defmodule Pleroma.User do 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) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index ec605b694..bab272323 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -554,12 +554,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do "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