Commit 44a86951 authored by feld's avatar feld
Browse files

Merge branch 'develop' into refactor/approval_pending_user_field

parents 63923df0 0ad6ea20
Pipeline #34195 passed with stages
in 5 minutes and 46 seconds
......@@ -8,10 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
- **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
- Polls now always return a `voters_count`, even if they are single-choice.
- Admin Emails: The ap id is used as the user link in emails now.
- Improved registration workflow for email confirmation and account approval modes.
- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
- Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
- Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
- Admin API: Reports now ordered by newest
......@@ -40,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Mastodon API: User and conversation mutes can now auto-expire if `expires_in` parameter was given while adding the mute.
- Admin API: An endpoint to manage frontends.
- Streaming API: Add follow relationships updates.
- WebPush: Introduce `pleroma:chat_mention` and `pleroma:emoji_reaction` notification types
</details>
### Fixed
......@@ -57,9 +59,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased (Patch)
### Fixed
- Fix ability to update Pleroma Chat push notifications with PUT /api/v1/push/subscription and alert type pleroma:chat_mention
- Emoji Reaction activity filtering from blocked and muted accounts.
- StealEmojiPolicy creates dir for emojis, if it doesn't exist.
## [2.2.1] - 2020-12-22
......@@ -76,6 +75,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Rich Media Previews sometimes showed the wrong preview due to a bug following redirects.
- Fixes for the autolinker.
- Forwarded reports duplication from Pleroma instances.
- Emoji Reaction activity filtering from blocked and muted accounts.
- <details>
<summary>API</summary>
......
......@@ -542,7 +542,7 @@
scheduled_activities: 10,
background: 5,
remote_fetcher: 2,
attachments_cleanup: 5,
attachments_cleanup: 1,
new_users_digest: 1,
mute_expire: 5
],
......
......@@ -34,7 +34,7 @@ def run(["resend_confirmation_emails"]) do
Pleroma.User.Query.build(%{
local: true,
deactivated: false,
confirmation_pending: true,
is_confirmed: false,
invisible: false
})
|> Pleroma.Repo.chunk_stream(500)
......
......@@ -74,7 +74,7 @@ def run(["new", nickname, email | rest]) do
bio: bio
}
changeset = User.register_changeset(%User{}, params, need_confirmation: false)
changeset = User.register_changeset(%User{}, params, is_confirmed: true)
{:ok, _user} = User.register(changeset)
shell_info("User #{nickname} created")
......@@ -213,7 +213,7 @@ def run(["set", nickname | rest]) do
user =
case Keyword.get(options, :confirmed) do
nil -> user
value -> set_confirmed(user, value)
value -> set_confirmation(user, value)
end
user =
......@@ -351,7 +351,7 @@ def run(["confirm", nickname]) do
with %User{} = user <- User.get_cached_by_nickname(nickname) do
{:ok, user} = User.confirm(user)
message = if user.confirmation_pending, do: "needs", else: "doesn't need"
message = if !user.is_confirmed, do: "needs", else: "doesn't need"
shell_info("#{nickname} #{message} confirmation.")
else
......@@ -373,7 +373,7 @@ def run(["confirm_all"]) do
|> Pleroma.Repo.chunk_stream(500, :batches)
|> Stream.each(fn users ->
users
|> Enum.each(fn user -> User.need_confirmation(user, false) end)
|> Enum.each(fn user -> User.set_confirmation(user, true) end)
end)
|> Stream.run()
end
......@@ -391,7 +391,7 @@ def run(["unconfirm_all"]) do
|> Pleroma.Repo.chunk_stream(500, :batches)
|> Stream.each(fn users ->
users
|> Enum.each(fn user -> User.need_confirmation(user, true) end)
|> Enum.each(fn user -> User.set_confirmation(user, false) end)
end)
|> Stream.run()
end
......@@ -454,10 +454,10 @@ defp set_locked(user, value) do
user
end
defp set_confirmed(user, value) do
{:ok, user} = User.need_confirmation(user, !value)
defp set_confirmation(user, value) do
{:ok, user} = User.set_confirmation(user, value)
shell_info("Confirmation pending status of #{user.nickname}: #{user.confirmation_pending}")
shell_info("Confirmation status of #{user.nickname}: #{user.is_confirmed}")
user
end
end
......@@ -110,7 +110,7 @@ defmodule Pleroma.User do
field(:follower_count, :integer, default: 0)
field(:following_count, :integer, default: 0)
field(:is_locked, :boolean, default: false)
field(:confirmation_pending, :boolean, default: false)
field(:is_confirmed, :boolean, default: true)
field(:password_reset_pending, :boolean, default: false)
field(:is_approved, :boolean, default: true)
field(:registration_reason, :string, default: nil)
......@@ -290,7 +290,7 @@ def account_status(%User{deactivated: true}), do: :deactivated
def account_status(%User{password_reset_pending: true}), do: :password_reset_pending
def account_status(%User{local: true, is_approved: false}), do: :approval_pending
def account_status(%User{local: true, confirmation_pending: true}) do
def account_status(%User{local: true, is_confirmed: false}) do
if Config.get([:instance, :account_activation_required]) do
:confirmation_pending
else
......@@ -704,11 +704,11 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
reason_limit = Config.get([:instance, :registration_reason_length], 500)
params = Map.put_new(params, :accepts_chat_messages, true)
need_confirmation? =
if is_nil(opts[:need_confirmation]) do
Config.get([:instance, :account_activation_required])
confirmed? =
if is_nil(opts[:confirmed]) do
!Config.get([:instance, :account_activation_required])
else
opts[:need_confirmation]
opts[:confirmed]
end
approved? =
......@@ -719,7 +719,7 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
end
struct
|> confirmation_changeset(need_confirmation: need_confirmation?)
|> confirmation_changeset(set_confirmation: confirmed?)
|> approval_changeset(set_approval: approved?)
|> cast(params, [
:bio,
......@@ -808,7 +808,7 @@ def register(%Ecto.Changeset{} = changeset) do
end
end
def post_register_action(%User{confirmation_pending: true} = user) do
def post_register_action(%User{is_confirmed: false} = user) do
with {:ok, _} <- try_send_confirmation_email(user) do
{:ok, user}
end
......@@ -821,7 +821,7 @@ def post_register_action(%User{is_approved: false} = user) do
end
end
def post_register_action(%User{is_approved: true, confirmation_pending: false} = user) do
def post_register_action(%User{is_approved: true, is_confirmed: true} = user) do
with {:ok, user} <- autofollow_users(user),
{:ok, _} <- autofollowing_users(user),
{:ok, user} <- set_cache(user),
......@@ -882,7 +882,7 @@ def send_welcome_email(%User{email: email} = user) when is_binary(email) do
def send_welcome_email(_), do: {:ok, :noop}
@spec try_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop}
def try_send_confirmation_email(%User{confirmation_pending: true, email: email} = user)
def try_send_confirmation_email(%User{is_confirmed: false, email: email} = user)
when is_binary(email) do
if Config.get([:instance, :account_activation_required]) do
send_confirmation_email(user)
......@@ -1642,8 +1642,8 @@ def confirm(users) when is_list(users) do
end)
end
def confirm(%User{confirmation_pending: true} = user) do
with chg <- confirmation_changeset(user, need_confirmation: false),
def confirm(%User{is_confirmed: false} = user) do
with chg <- confirmation_changeset(user, set_confirmation: true),
{:ok, user} <- update_and_set_cache(chg) do
post_register_action(user)
{:ok, user}
......@@ -1682,7 +1682,7 @@ def purge_user_changeset(user) do
follower_count: 0,
following_count: 0,
is_locked: false,
confirmation_pending: false,
is_confirmed: true,
password_reset_pending: false,
is_approved: true,
registration_reason: nil,
......@@ -2138,10 +2138,10 @@ def touch_last_digest_emailed_at(user) do
updated_user
end
@spec need_confirmation(User.t(), boolean()) :: {:ok, User.t()} | {:error, Changeset.t()}
def need_confirmation(%User{} = user, bool) do
@spec set_confirmation(User.t(), boolean()) :: {:ok, User.t()} | {:error, Changeset.t()}
def set_confirmation(%User{} = user, bool) do
user
|> confirmation_changeset(need_confirmation: bool)
|> confirmation_changeset(set_confirmation: bool)
|> update_and_set_cache()
end
......@@ -2309,21 +2309,21 @@ def mastodon_settings_update(user, settings) do
end
@spec confirmation_changeset(User.t(), keyword()) :: Changeset.t()
def confirmation_changeset(user, need_confirmation: need_confirmation?) do
def confirmation_changeset(user, set_confirmation: confirmed?) do
params =
if need_confirmation? do
if confirmed? do
%{
confirmation_pending: true,
confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64()
is_confirmed: true,
confirmation_token: nil
}
else
%{
confirmation_pending: false,
confirmation_token: nil
is_confirmed: false,
confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64()
}
end
cast(user, params, [:confirmation_pending, :confirmation_token])
cast(user, params, [:is_confirmed, :confirmation_token])
end
@spec approval_changeset(User.t(), keyword()) :: Changeset.t()
......
......@@ -155,7 +155,7 @@ defp compose_query({:deactivated, true}, query) do
end
defp compose_query({:confirmation_pending, bool}, query) do
where(query, [u], u.confirmation_pending == ^bool)
where(query, [u], u.is_confirmed != ^bool)
end
defp compose_query({:need_approval, _}, query) do
......@@ -163,7 +163,7 @@ defp compose_query({:need_approval, _}, query) do
end
defp compose_query({:unconfirmed, _}, query) do
where(query, [u], u.confirmation_pending)
where(query, [u], u.is_confirmed == false)
end
defp compose_query({:followers, %User{id: id}}, query) do
......
......@@ -77,7 +77,7 @@ def render("show.json", %{user: user}) do
"local" => user.local,
"roles" => User.roles(user),
"tags" => user.tags || [],
"confirmation_pending" => user.confirmation_pending,
"is_confirmed" => user.is_confirmed,
"is_approved" => user.is_approved,
"url" => user.uri || user.ap_id,
"registration_reason" => user.registration_reason,
......
......@@ -191,7 +191,7 @@ defp account_admin do
moderator: %Schema{type: :boolean}
}
},
confirmation_pending: %Schema{type: :boolean}
is_confirmed: %Schema{type: :boolean}
})
}
end
......
......@@ -142,7 +142,7 @@ def admin_account do
}
},
tags: %Schema{type: :string},
confirmation_pending: %Schema{type: :string}
is_confirmed: %Schema{type: :string}
}
}
end
......
......@@ -236,7 +236,7 @@ def chats_response do
"account" => %{
"pleroma" => %{
"is_admin" => false,
"confirmation_pending" => false,
"is_confirmed" => true,
"hide_followers_count" => false,
"is_moderator" => false,
"hide_favorites" => true,
......
......@@ -48,7 +48,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
},
background_image: %Schema{type: :string, nullable: true, format: :uri},
chat_token: %Schema{type: :string},
confirmation_pending: %Schema{
is_confirmed: %Schema{
type: :boolean,
description:
"whether the user account is waiting on email confirmation to be activated"
......@@ -166,7 +166,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
"pleroma" => %{
"allow_following_move" => true,
"background_image" => nil,
"confirmation_pending" => true,
"is_confirmed" => false,
"hide_favorites" => true,
"hide_followers" => false,
"hide_followers_count" => false,
......
......@@ -23,7 +23,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
"account" => %{
"pleroma" => %{
"is_admin" => false,
"confirmation_pending" => false,
"is_confirmed" => true,
"hide_followers_count" => false,
"is_moderator" => false,
"hide_favorites" => true,
......
......@@ -256,7 +256,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
"note" => "Tester Number 6",
"pleroma" => %{
"background_image" => nil,
"confirmation_pending" => false,
"is_confirmed" => true,
"hide_favorites" => true,
"hide_followers" => false,
"hide_followers_count" => false,
......
......@@ -84,7 +84,7 @@ def create_from_registration(
password_confirmation: random_password
},
external: true,
need_confirmation: false
confirmed: true
)
|> Repo.insert(),
{:ok, _} <-
......
......@@ -266,7 +266,7 @@ defp do_render("show.json", %{user: user} = opts) do
pleroma: %{
ap_id: user.ap_id,
also_known_as: user.also_known_as,
confirmation_pending: user.confirmation_pending,
is_confirmed: user.is_confirmed,
tags: user.tags,
hide_followers_count: user.hide_followers_count,
hide_follows_count: user.hide_follows_count,
......
......@@ -30,7 +30,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def confirm_email(conn, %{"user_id" => uid, "token" => token}) do
with %User{} = user <- User.get_cached_by_id(uid),
true <- user.local and user.confirmation_pending and user.confirmation_token == token,
true <- user.local and !user.is_confirmed and user.confirmation_token == token,
{:ok, _} <- User.confirm(user) do
redirect(conn, to: "/")
end
......
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.RefactorConfirmationPendingUserField do
use Ecto.Migration
def up do
# Flip the values before we change the meaning of the column
execute("UPDATE users SET confirmation_pending = NOT confirmation_pending;")
execute("ALTER TABLE users RENAME COLUMN confirmation_pending TO is_confirmed;")
execute("ALTER TABLE users ALTER COLUMN is_confirmed SET DEFAULT true;")
end
def down do
execute("UPDATE users SET is_confirmed = NOT is_confirmed;")
execute("ALTER TABLE users RENAME COLUMN is_confirmed TO confirmation_pending;")
execute("ALTER TABLE users ALTER COLUMN confirmation_pending SET DEFAULT false;")
end
end
......@@ -11,9 +11,9 @@ defmodule Pleroma.Repo.Migrations.ConfirmLoggedInUsers do
def up do
User
|> where([u], u.confirmation_pending == true)
|> where([u], u.is_confirmed == false)
|> join(:inner, [u], t in Token, on: t.user_id == u.id)
|> Repo.update_all(set: [confirmation_pending: false])
|> Repo.update_all(set: [is_confirmed: true])
end
def down do
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment