From 2887f4ff1d32c8fbe7a90ac921823794264f7157 Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 20 Nov 2018 19:07:01 +0100 Subject: [PATCH] Fix formatter tests. --- lib/pleroma/user.ex | 6 +++--- lib/pleroma/user/info.ex | 7 ++++++- test/formatter_test.exs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 565218b4c..03fe2f1d4 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -87,7 +87,7 @@ defmodule Pleroma.User do info_cng = User.Info.remote_user_creation(%User.Info{}, params[:info]) changes = - %User{info: %{}} + %User{} |> cast(params, [:bio, :name, :ap_id, :nickname, :avatar]) |> validate_required([:name, :ap_id]) |> unique_constraint(:nickname) @@ -718,7 +718,7 @@ defmodule Pleroma.User do user else changes = - %User{info: %{}} + %User{info: %User.Info{}} |> cast(%{}, [:ap_id, :nickname, :local]) |> put_change(:ap_id, relay_uri) |> put_change(:nickname, nil) @@ -763,9 +763,9 @@ defmodule Pleroma.User do data = data |> Map.put(:name, blank?(data[:name]) || data[:nickname]) - |> Map.put(:info, data[:info] || %{}) cs = User.remote_user_creation(data) + Repo.insert(cs, on_conflict: :replace_all, conflict_target: :nickname) end diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 48f3a4d4a..7d5df34ba 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -89,7 +89,12 @@ defmodule Pleroma.User.Info do def remote_user_creation(info, params) do info - |> cast(params, [:source_data]) + |> cast(params, [ + :ap_enabled, + :source_data, + :banner, + :locked + ]) end # Receives data from user_data_from_user_object diff --git a/test/formatter_test.exs b/test/formatter_test.exs index 13084baa7..e4da84c10 100644 --- a/test/formatter_test.exs +++ b/test/formatter_test.exs @@ -110,7 +110,7 @@ defmodule Pleroma.FormatterTest do archaeme = insert(:user, %{ nickname: "archaeme", - info: %{"source_data" => %{"url" => "https://archeme/@archaeme"}} + info: %Pleroma.User.Info{source_data: %{"url" => "https://archeme/@archaeme"}} }) archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})