Merge branch 'remove-info-from-users' into 'develop'

Removed users.info field

See merge request pleroma/pleroma!2006
This commit is contained in:
rinpatch 2019-11-30 10:42:51 +00:00
commit 0d24ab04c5
5 changed files with 14 additions and 27 deletions

View file

@ -49,7 +49,6 @@ defmodule Pleroma.LoadTesting.Generator do
password_hash: password_hash:
"$pbkdf2-sha512$160000$bU.OSFI7H/yqWb5DPEqyjw$uKp/2rmXw12QqnRRTqTtuk2DTwZfF8VR4MYW2xMeIlqPR/UX1nT1CEKVUx2CowFMZ5JON8aDvURrZpJjSgqXrg", "$pbkdf2-sha512$160000$bU.OSFI7H/yqWb5DPEqyjw$uKp/2rmXw12QqnRRTqTtuk2DTwZfF8VR4MYW2xMeIlqPR/UX1nT1CEKVUx2CowFMZ5JON8aDvURrZpJjSgqXrg",
bio: "Tester Number #{i}", bio: "Tester Number #{i}",
info: %{},
local: remote local: remote
} }

View file

@ -118,8 +118,6 @@ defmodule Pleroma.User do
has_many(:registrations, Registration) has_many(:registrations, Registration)
has_many(:deliveries, Delivery) has_many(:deliveries, Delivery)
field(:info, :map, default: %{})
timestamps() timestamps()
end end
@ -225,7 +223,6 @@ defmodule Pleroma.User do
params = params =
params params
|> Map.put(:info, params[:info] || %{})
|> truncate_if_exists(:name, name_limit) |> truncate_if_exists(:name, name_limit)
|> truncate_if_exists(:bio, bio_limit) |> truncate_if_exists(:bio, bio_limit)
|> truncate_fields_param() |> truncate_fields_param()
@ -1211,7 +1208,7 @@ defmodule Pleroma.User do
def external_users(opts \\ []) do def external_users(opts \\ []) do
query = query =
external_users_query() external_users_query()
|> select([u], struct(u, [:id, :ap_id, :info])) |> select([u], struct(u, [:id, :ap_id]))
query = query =
if opts[:max_id], if opts[:max_id],

View file

@ -0,0 +1,9 @@
defmodule Pleroma.Repo.Migrations.RemoveInfoFromUsers do
use Ecto.Migration
def change do
alter table(:users) do
remove(:info, :map, default: %{})
end
end
end

View file

@ -31,7 +31,6 @@ defmodule Pleroma.Factory do
nickname: sequence(:nickname, &"nick#{&1}"), nickname: sequence(:nickname, &"nick#{&1}"),
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"), password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: sequence(:bio, &"Tester Number #{&1}"), bio: sequence(:bio, &"Tester Number #{&1}"),
info: %{},
last_digest_emailed_at: NaiveDateTime.utc_now() last_digest_emailed_at: NaiveDateTime.utc_now()
} }

View file

@ -367,18 +367,6 @@ defmodule Pleroma.UserTest do
assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers" assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers"
end end
test "it ensures info is not nil" do
changeset = User.register_changeset(%User{}, @full_user_data)
assert changeset.valid?
{:ok, user} =
changeset
|> Repo.insert()
refute is_nil(user.info)
end
end end
describe "user registration, with :account_activation_required" do describe "user registration, with :account_activation_required" do
@ -432,8 +420,7 @@ defmodule Pleroma.UserTest do
:user, :user,
local: false, local: false,
nickname: "admin@mastodon.example.org", nickname: "admin@mastodon.example.org",
ap_id: ap_id, ap_id: ap_id
info: %{}
) )
{:ok, fetched_user} = User.get_or_fetch(ap_id) {:ok, fetched_user} = User.get_or_fetch(ap_id)
@ -494,8 +481,7 @@ defmodule Pleroma.UserTest do
local: false, local: false,
nickname: "admin@mastodon.example.org", nickname: "admin@mastodon.example.org",
ap_id: "http://mastodon.example.org/users/admin", ap_id: "http://mastodon.example.org/users/admin",
last_refreshed_at: a_week_ago, last_refreshed_at: a_week_ago
info: %{}
) )
assert orig_user.last_refreshed_at == a_week_ago assert orig_user.last_refreshed_at == a_week_ago
@ -536,7 +522,6 @@ defmodule Pleroma.UserTest do
name: "Someone", name: "Someone",
nickname: "a@b.de", nickname: "a@b.de",
ap_id: "http...", ap_id: "http...",
info: %{some: "info"},
avatar: %{some: "avatar"} avatar: %{some: "avatar"}
} }
@ -1143,8 +1128,7 @@ defmodule Pleroma.UserTest do
ap_id: user.ap_id, ap_id: user.ap_id,
name: user.name, name: user.name,
nickname: user.nickname, nickname: user.nickname,
bio: String.duplicate("h", current_max_length + 1), bio: String.duplicate("h", current_max_length + 1)
info: %{}
} }
assert {:ok, %User{}} = User.insert_or_update_user(data) assert {:ok, %User{}} = User.insert_or_update_user(data)
@ -1157,8 +1141,7 @@ defmodule Pleroma.UserTest do
data = %{ data = %{
ap_id: user.ap_id, ap_id: user.ap_id,
name: String.duplicate("h", current_max_length + 1), name: String.duplicate("h", current_max_length + 1),
nickname: user.nickname, nickname: user.nickname
info: %{}
} }
assert {:ok, %User{}} = User.insert_or_update_user(data) assert {:ok, %User{}} = User.insert_or_update_user(data)