def visible_for?(_, _), do: false
- def superuser?(%User{local: true, info: %User.Info{is_admin: true}}), do: true
- def superuser?(%User{local: true, info: %User.Info{is_moderator: true}}), do: true
+ def superuser?(%User{local: true, is_admin: true}), do: true
+ def superuser?(%User{local: true, is_moderator: true}), do: true
def superuser?(_), do: false
+ def invisible?(%User{info: %User.Info{invisible: true}}), do: true
+ def invisible?(_), do: false
+
def avatar_url(user, options \\ []) do
case user.avatar do
%{"url" => [%{"href" => href} | _]} -> href
user_data = %{
ap_id: data["id"],
- banner: banner,
- discoverable: discoverable,
- info: %{
- ap_enabled: true,
- source_data: data,
- banner: banner,
- fields: fields,
- locked: locked,
- discoverable: discoverable,
- invisible: invisible
- },
++ ap_enabled: true,
+ source_data: data,
++ banner: banner,
+ fields: fields,
+ locked: locked,
- ap_enabled: true,
++ discoverable: discoverable,
++ invisible: invisible,
avatar: avatar,
name: data["name"],
follower_address: data["followers"],
with %User{ap_id: ^actor_id} = actor <- User.get_cached_by_ap_id(object["id"]) do
{:ok, new_user_data} = ActivityPub.user_data_from_user_object(object)
- banner = new_user_data[:info][:banner]
- locked = new_user_data[:info][:locked] || false
- attachment = get_in(new_user_data, [:info, :source_data, "attachment"]) || []
- invisible = new_user_data[:info][:invisible] || false
+ locked = new_user_data[:locked] || false
+ attachment = get_in(new_user_data, [:source_data, "attachment"]) || []
++ invisible = new_user_data[:invisible] || false
fields =
attachment
update_data =
new_user_data
- |> Map.take([:name, :bio, :avatar])
- |> Map.put(:info, %{banner: banner, locked: locked, fields: fields, invisible: invisible})
+ |> Map.take([:avatar, :banner, :bio, :name])
+ |> Map.put(:fields, fields)
+ |> Map.put(:locked, locked)
++ |> Map.put(:invisible, invisible)
actor
|> User.upgrade_changeset(update_data, true)