field(:no_rich_text, :boolean, default: false)
field(:ap_enabled, :boolean, default: false)
field(:is_moderator, :boolean, default: false)
- field(:keys, :map, default: %{})
+ field(:keys, :string, default: nil)
end
def set_activation_status(info, deactivated) do
def remove_from_block(info, blocked) do
set_blocks(info, List.delete(info.blocks, blocked))
end
+
+ def set_keys(info, keys) do
+ params = %{keys: keys}
+
+ info
+ |> cast(params, [:keys])
+ |> validate_required([:keys])
+ end
end
# This seems a better fit in Salmon
def ensure_keys_present(user) do
- info = user.info || %{}
+ info = user.info
- if info["keys"] do
+ if info.keys do
{:ok, user}
else
{:ok, pem} = Salmon.generate_rsa_pem()
- info = Map.put(info, "keys", pem)
- Ecto.Changeset.change(user, info: info)
- |> User.update_and_set_cache()
+ info_cng = info
+ |> Pleroma.User.Info.set_keys(pem)
+
+ cng = Ecto.Changeset.change(user)
+ |> Ecto.Changeset.put_embed(:info, info_cng)
+
+ User.update_and_set_cache(cng)
end
end