Merge branch 'refactor/approval_pending_user_field' into 'develop'

Change user.approval_pending field to user.is_approved

See merge request pleroma/pleroma!3090
This commit is contained in:
feld 2021-01-18 19:58:30 +00:00
commit ed84210da3
34 changed files with 94 additions and 74 deletions

View file

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
- **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
- **Breaking**: AdminAPI changed User field `approval_pending` to `is_approved`
- 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.

View file

@ -112,7 +112,7 @@ defmodule Pleroma.User do
field(:is_locked, :boolean, default: false)
field(:is_confirmed, :boolean, default: true)
field(:password_reset_pending, :boolean, default: false)
field(:approval_pending, :boolean, default: false)
field(:is_approved, :boolean, default: true)
field(:registration_reason, :string, default: nil)
field(:confirmation_token, :string, default: nil)
field(:default_scope, :string, default: "public")
@ -288,7 +288,7 @@ def binary_id(%User{} = user), do: binary_id(user.id)
@spec account_status(User.t()) :: account_status()
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, approval_pending: true}), do: :approval_pending
def account_status(%User{local: true, is_approved: false}), do: :approval_pending
def account_status(%User{local: true, is_confirmed: false}) do
if Config.get([:instance, :account_activation_required]) do
@ -711,16 +711,16 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
opts[:confirmed]
end
need_approval? =
if is_nil(opts[:need_approval]) do
Config.get([:instance, :account_approval_required])
approved? =
if is_nil(opts[:approved]) do
!Config.get([:instance, :account_approval_required])
else
opts[:need_approval]
opts[:approved]
end
struct
|> confirmation_changeset(set_confirmation: confirmed?)
|> approval_changeset(need_approval: need_approval?)
|> approval_changeset(set_approval: approved?)
|> cast(params, [
:bio,
:raw_bio,
@ -814,14 +814,14 @@ def post_register_action(%User{is_confirmed: false} = user) do
end
end
def post_register_action(%User{approval_pending: true} = user) do
def post_register_action(%User{is_approved: false} = user) do
with {:ok, _} <- send_user_approval_email(user),
{:ok, _} <- send_admin_approval_emails(user) do
{:ok, user}
end
end
def post_register_action(%User{approval_pending: false, is_confirmed: true} = 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),
@ -1624,8 +1624,8 @@ def approve(users) when is_list(users) do
end)
end
def approve(%User{approval_pending: true} = user) do
with chg <- change(user, approval_pending: false),
def approve(%User{is_approved: false} = user) do
with chg <- change(user, is_approved: true),
{:ok, user} <- update_and_set_cache(chg) do
post_register_action(user)
{:ok, user}
@ -1684,7 +1684,7 @@ def purge_user_changeset(user) do
is_locked: false,
is_confirmed: true,
password_reset_pending: false,
approval_pending: false,
is_approved: true,
registration_reason: nil,
confirmation_token: nil,
domain_blocks: [],
@ -2327,9 +2327,8 @@ def confirmation_changeset(user, set_confirmation: confirmed?) do
end
@spec approval_changeset(User.t(), keyword()) :: Changeset.t()
def approval_changeset(user, need_approval: need_approval?) do
params = if need_approval?, do: %{approval_pending: true}, else: %{approval_pending: false}
cast(user, params, [:approval_pending])
def approval_changeset(user, set_approval: approved?) do
cast(user, %{is_approved: approved?}, [:is_approved])
end
def add_pinnned_activity(user, %Pleroma.Activity{id: id}) do

View file

@ -138,7 +138,7 @@ defp compose_query({:external, _}, query), do: location_query(query, false)
defp compose_query({:active, _}, query) do
User.restrict_deactivated(query)
|> where([u], u.approval_pending == false)
|> where([u], u.is_approved == true)
end
defp compose_query({:legacy_active, _}, query) do
@ -159,7 +159,7 @@ defp compose_query({:confirmation_pending, bool}, query) do
end
defp compose_query({:need_approval, _}, query) do
where(query, [u], u.approval_pending)
where(query, [u], u.is_approved == false)
end
defp compose_query({:unconfirmed, _}, query) do

View file

@ -78,7 +78,7 @@ def render("show.json", %{user: user}) do
"roles" => User.roles(user),
"tags" => user.tags || [],
"is_confirmed" => user.is_confirmed,
"approval_pending" => user.approval_pending,
"is_approved" => user.is_approved,
"url" => user.uri || user.ap_id,
"registration_reason" => user.registration_reason,
"actor_type" => user.actor_type

View file

@ -0,0 +1,20 @@
# 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.RefactorApprovalPendingUserField do
use Ecto.Migration
def up do
# Flip the values before we change the meaning of the column
execute("UPDATE users SET approval_pending = NOT approval_pending;")
execute("ALTER TABLE users RENAME COLUMN approval_pending TO is_approved;")
execute("ALTER TABLE users ALTER COLUMN is_approved SET DEFAULT true;")
end
def down do
execute("UPDATE users SET is_approved = NOT is_approved;")
execute("ALTER TABLE users RENAME COLUMN is_approved TO approval_pending;")
execute("ALTER TABLE users ALTER COLUMN approval_pending SET DEFAULT false;")
end
end

View file

@ -1 +1 @@
.actions-button[data-v-4c2a46a6]{text-align:left;width:350px;padding:10px}.actions-button-container[data-v-4c2a46a6]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.el-dropdown[data-v-4c2a46a6]{float:right}.el-icon-edit[data-v-4c2a46a6]{margin-right:5px}.tag-container[data-v-4c2a46a6]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.tag-text[data-v-4c2a46a6]{padding-right:20px}.no-hover[data-v-4c2a46a6]:hover{color:#606266;background-color:#fff;cursor:auto}
.actions-button[data-v-758e95f2]{text-align:left;width:350px;padding:10px}.actions-button-container[data-v-758e95f2]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.el-dropdown[data-v-758e95f2]{float:right}.el-icon-edit[data-v-758e95f2]{margin-right:5px}.tag-container[data-v-758e95f2]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.tag-text[data-v-758e95f2]{padding-right:20px}.no-hover[data-v-758e95f2]:hover{color:#606266;background-color:#fff;cursor:auto}

View file

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=renderer content=webkit><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><title>Admin FE</title><link rel="shortcut icon" href=favicon.ico><link href=chunk-elementUI.f77689d7.css rel=stylesheet><link href=chunk-libs.5cf7f50a.css rel=stylesheet><link href=app.6fb984d1.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/runtime.52fd11cf.js></script><script type=text/javascript src=static/js/chunk-elementUI.21957ec8.js></script><script type=text/javascript src=static/js/chunk-libs.5ca2c8e8.js></script><script type=text/javascript src=static/js/app.3e54b198.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=renderer content=webkit><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><title>Admin FE</title><link rel="shortcut icon" href=favicon.ico><link href=chunk-elementUI.f77689d7.css rel=stylesheet><link href=chunk-libs.5cf7f50a.css rel=stylesheet><link href=app.6fb984d1.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/runtime.5c1034c4.js></script><script type=text/javascript src=static/js/chunk-elementUI.21957ec8.js></script><script type=text/javascript src=static/js/chunk-libs.5ca2c8e8.js></script><script type=text/javascript src=static/js/app.01bfc983.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,2 +0,0 @@
!function(e){function n(n){for(var t,r,a=n[0],f=n[1],h=n[2],i=0,s=[];i<a.length;i++)r=a[i],Object.prototype.hasOwnProperty.call(u,r)&&u[r]&&s.push(u[r][0]),u[r]=0;for(t in f)Object.prototype.hasOwnProperty.call(f,t)&&(e[t]=f[t]);for(k&&k(n);s.length;)s.shift()();return o.push.apply(o,h||[]),c()}function c(){for(var e,n=0;n<o.length;n++){for(var c=o[n],t=!0,r=1;r<c.length;r++){var f=c[r];0!==u[f]&&(t=!1)}t&&(o.splice(n--,1),e=a(a.s=c[0]))}return e}var t={},r={runtime:0},u={runtime:0},o=[];function a(n){if(t[n])return t[n].exports;var c=t[n]={i:n,l:!1,exports:{}};return e[n].call(c.exports,c,c.exports,a),c.l=!0,c.exports}a.e=function(e){var n=[];r[e]?n.push(r[e]):0!==r[e]&&{"chunk-68ea9":1,"chunk-6e81":1,"chunk-commons":1,"chunk-03c5":1,"chunk-0537":1,"chunk-50ba":1,"chunk-606c":1,"chunk-4770":1,"chunk-7c6b":1,"chunk-170f":1,"chunk-1e1e":1,"chunk-35b1":1,"chunk-176e":1,"chunk-7041":1,"chunk-7968":1,"chunk-f364":1,"chunk-e660":1}[e]&&n.push(r[e]=new Promise(function(n,c){for(var t=({"chunk-commons":"chunk-commons"}[e]||e)+"."+{"7zzA":"31d6cfe0",JEtC:"31d6cfe0","chunk-68ea9":"892994aa","chunk-6e81":"687d5046","chunk-commons":"f7c3d390","chunk-03c5":"3368e00c","chunk-0537":"76929cff","chunk-50ba":"6e4bf9f4","chunk-606c":"7c5b0a08","chunk-68ea":"31d6cfe0","chunk-4770":"20caaae1","chunk-7c6b":"b633878a","chunk-d55e":"31d6cfe0","chunk-170f":"fea927c5","chunk-1e1e":"5980e665","chunk-35b1":"949db050","chunk-176e":"d9a630b2","chunk-7041":"c5f6eab7","chunk-7968":"613084d0","chunk-f364":"4fd16c53",oAJy:"31d6cfe0","chunk-16d0":"31d6cfe0","chunk-e660":"62c077ac"}[e]+".css",r=a.p+t,u=document.getElementsByTagName("link"),o=0;o<u.length;o++){var f=(i=u[o]).getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(f===t||f===r))return n()}var h=document.getElementsByTagName("style");for(o=0;o<h.length;o++){var i;if((f=(i=h[o]).getAttribute("data-href"))===t||f===r)return n()}var k=document.createElement("link");k.rel="stylesheet",k.type="text/css",k.onload=n,k.onerror=function(n){var t=n&&n.target&&n.target.src||r,u=new Error("Loading CSS chunk "+e+" failed.\n("+t+")");u.request=t,c(u)},k.href=r,document.getElementsByTagName("head")[0].appendChild(k)}).then(function(){r[e]=0}));var c=u[e];if(0!==c)if(c)n.push(c[2]);else{var t=new Promise(function(n,t){c=u[e]=[n,t]});n.push(c[2]=t);var o,f=document.createElement("script");f.charset="utf-8",f.timeout=120,a.nc&&f.setAttribute("nonce",a.nc),f.src=function(e){return a.p+"static/js/"+({"chunk-commons":"chunk-commons"}[e]||e)+"."+{"7zzA":"e1ae1c94",JEtC:"f9ba4594","chunk-68ea9":"5a11341a","chunk-6e81":"6c4f2ce1","chunk-commons":"4ae74caa","chunk-03c5":"1b0ab243","chunk-0537":"d0eef370","chunk-50ba":"afb924bf","chunk-606c":"f5585a4f","chunk-68ea":"6d56674a","chunk-4770":"1c1fff97","chunk-7c6b":"34152862","chunk-d55e":"f9bab96d","chunk-170f":"e1d6aac3","chunk-1e1e":"37f6f555","chunk-35b1":"51b3140e","chunk-176e":"f64cb745","chunk-7041":"9658c334","chunk-7968":"d6317b83","chunk-f364":"f22b0eee",oAJy:"2d5429b2","chunk-16d0":"fef0ce65","chunk-e660":"2101cafc"}[e]+".js"}(e);var h=new Error;o=function(n){f.onerror=f.onload=null,clearTimeout(i);var c=u[e];if(0!==c){if(c){var t=n&&("load"===n.type?"missing":n.type),r=n&&n.target&&n.target.src;h.message="Loading chunk "+e+" failed.\n("+t+": "+r+")",h.name="ChunkLoadError",h.type=t,h.request=r,c[1](h)}u[e]=void 0}};var i=setTimeout(function(){o({type:"timeout",target:f})},12e4);f.onerror=f.onload=o,document.head.appendChild(f)}return Promise.all(n)},a.m=e,a.c=t,a.d=function(e,n,c){a.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:c})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,n){if(1&n&&(e=a(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(a.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var t in e)a.d(c,t,function(n){return e[n]}.bind(null,t));return c},a.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(n,"a",n),n},a.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},a.p="",a.oe=function(e){throw console.error(e),e};var f=window.webpackJsonp=window.webpackJsonp||[],h=f.push.bind(f);f.push=n,f=f.slice();for(var i=0;i<f.length;i++)n(f[i]);var k=h;c()}([]);
//# sourceMappingURL=runtime.52fd11cf.js.map

View file

@ -0,0 +1,2 @@
!function(e){function n(n){for(var t,r,a=n[0],h=n[1],f=n[2],i=0,k=[];i<a.length;i++)r=a[i],Object.prototype.hasOwnProperty.call(u,r)&&u[r]&&k.push(u[r][0]),u[r]=0;for(t in h)Object.prototype.hasOwnProperty.call(h,t)&&(e[t]=h[t]);for(d&&d(n);k.length;)k.shift()();return o.push.apply(o,f||[]),c()}function c(){for(var e,n=0;n<o.length;n++){for(var c=o[n],t=!0,r=1;r<c.length;r++){var h=c[r];0!==u[h]&&(t=!1)}t&&(o.splice(n--,1),e=a(a.s=c[0]))}return e}var t={},r={runtime:0},u={runtime:0},o=[];function a(n){if(t[n])return t[n].exports;var c=t[n]={i:n,l:!1,exports:{}};return e[n].call(c.exports,c,c.exports,a),c.l=!0,c.exports}a.e=function(e){var n=[];r[e]?n.push(r[e]):0!==r[e]&&{"chunk-68ea9":1,"chunk-6e81":1,"chunk-commons":1,"chunk-03c5":1,"chunk-0537":1,"chunk-1e46":1,"chunk-606c":1,"chunk-4770":1,"chunk-7c6b":1,"chunk-170f":1,"chunk-1e1e":1,"chunk-176e":1,"chunk-35b1":1,"chunk-7041":1,"chunk-7968":1,"chunk-f364":1,"chunk-e660":1}[e]&&n.push(r[e]=new Promise(function(n,c){for(var t=({"chunk-commons":"chunk-commons"}[e]||e)+"."+{"7zzA":"31d6cfe0",JEtC:"31d6cfe0","chunk-68ea9":"892994aa","chunk-6e81":"687d5046","chunk-commons":"f7c3d390","chunk-03c5":"3368e00c","chunk-0537":"76929cff","chunk-1e46":"0411a9b2","chunk-606c":"7c5b0a08","chunk-68ea":"31d6cfe0","chunk-4770":"20caaae1","chunk-7c6b":"b633878a","chunk-d55e":"31d6cfe0","chunk-170f":"fea927c5","chunk-1e1e":"5980e665","chunk-176e":"d9a630b2","chunk-35b1":"949db050","chunk-7041":"c5f6eab7","chunk-7968":"613084d0","chunk-f364":"4fd16c53",oAJy:"31d6cfe0","chunk-16d0":"31d6cfe0","chunk-e660":"62c077ac"}[e]+".css",r=a.p+t,u=document.getElementsByTagName("link"),o=0;o<u.length;o++){var h=(i=u[o]).getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(h===t||h===r))return n()}var f=document.getElementsByTagName("style");for(o=0;o<f.length;o++){var i;if((h=(i=f[o]).getAttribute("data-href"))===t||h===r)return n()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=n,d.onerror=function(n){var t=n&&n.target&&n.target.src||r,u=new Error("Loading CSS chunk "+e+" failed.\n("+t+")");u.request=t,c(u)},d.href=r,document.getElementsByTagName("head")[0].appendChild(d)}).then(function(){r[e]=0}));var c=u[e];if(0!==c)if(c)n.push(c[2]);else{var t=new Promise(function(n,t){c=u[e]=[n,t]});n.push(c[2]=t);var o,h=document.createElement("script");h.charset="utf-8",h.timeout=120,a.nc&&h.setAttribute("nonce",a.nc),h.src=function(e){return a.p+"static/js/"+({"chunk-commons":"chunk-commons"}[e]||e)+"."+{"7zzA":"e1ae1c94",JEtC:"f9ba4594","chunk-68ea9":"5a11341a","chunk-6e81":"6c4f2ce1","chunk-commons":"4ae74caa","chunk-03c5":"1b0ab243","chunk-0537":"d0eef370","chunk-1e46":"7c2ee531","chunk-606c":"35588dea","chunk-68ea":"6d56674a","chunk-4770":"1c1fff97","chunk-7c6b":"34152862","chunk-d55e":"f9bab96d","chunk-170f":"e1d6aac3","chunk-1e1e":"37f6f555","chunk-176e":"f64cb745","chunk-35b1":"ddb9524c","chunk-7041":"1495e01c","chunk-7968":"d6317b83","chunk-f364":"f22b0eee",oAJy:"2d5429b2","chunk-16d0":"fef0ce65","chunk-e660":"2101cafc"}[e]+".js"}(e);var f=new Error;o=function(n){h.onerror=h.onload=null,clearTimeout(i);var c=u[e];if(0!==c){if(c){var t=n&&("load"===n.type?"missing":n.type),r=n&&n.target&&n.target.src;f.message="Loading chunk "+e+" failed.\n("+t+": "+r+")",f.name="ChunkLoadError",f.type=t,f.request=r,c[1](f)}u[e]=void 0}};var i=setTimeout(function(){o({type:"timeout",target:h})},12e4);h.onerror=h.onload=o,document.head.appendChild(h)}return Promise.all(n)},a.m=e,a.c=t,a.d=function(e,n,c){a.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:c})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,n){if(1&n&&(e=a(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(a.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var t in e)a.d(c,t,function(n){return e[n]}.bind(null,t));return c},a.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(n,"a",n),n},a.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},a.p="",a.oe=function(e){throw console.error(e),e};var h=window.webpackJsonp=window.webpackJsonp||[],f=h.push.bind(h);h.push=n,h=h.slice();for(var i=0;i<h.length;i++)n(h[i]);var d=f;c()}([]);
//# sourceMappingURL=runtime.5c1034c4.js.map

View file

@ -694,7 +694,7 @@ test "it creates unapproved user" do
{:ok, user} = Repo.insert(changeset)
assert user.approval_pending
refute user.is_approved
assert user.registration_reason == "I'm a cool guy :)"
end
@ -1388,17 +1388,17 @@ test "hide a user's statuses from timelines and notifications" do
describe "approve" do
test "approves a user" do
user = insert(:user, approval_pending: true)
assert true == user.approval_pending
user = insert(:user, is_approved: false)
refute user.is_approved
{:ok, user} = User.approve(user)
assert false == user.approval_pending
assert user.is_approved
end
test "approves a list of users" do
unapproved_users = [
insert(:user, approval_pending: true),
insert(:user, approval_pending: true),
insert(:user, approval_pending: true)
insert(:user, is_approved: false),
insert(:user, is_approved: false),
insert(:user, is_approved: false)
]
{:ok, users} = User.approve(unapproved_users)
@ -1406,7 +1406,7 @@ test "approves a list of users" do
assert Enum.count(users) == 3
Enum.each(users, fn user ->
assert false == user.approval_pending
assert user.is_approved
end)
end
@ -1414,7 +1414,7 @@ test "it sends welcome email if it is set" do
clear_config([:welcome, :email, :enabled], true)
clear_config([:welcome, :email, :sender], "tester@test.me")
user = insert(:user, approval_pending: true)
user = insert(:user, is_approved: false)
welcome_user = insert(:user, email: "tester@test.me")
instance_name = Pleroma.Config.get([:instance, :name])
@ -1432,7 +1432,7 @@ test "it sends welcome email if it is set" do
test "approving an approved user does not trigger post-register actions" do
clear_config([:welcome, :email, :enabled], true)
user = insert(:user, approval_pending: false)
user = insert(:user, is_approved: true)
User.approve(user)
ObanHelpers.perform_all()
@ -1465,9 +1465,9 @@ test "confirms a list of users" do
end)
end
test "sends approval emails when `approval_pending: true`" do
test "sends approval emails when `is_approved: false`" do
admin = insert(:user, is_admin: true)
user = insert(:user, is_confirmed: false, approval_pending: true)
user = insert(:user, is_confirmed: false, is_approved: false)
User.confirm(user)
ObanHelpers.perform_all()
@ -1494,7 +1494,7 @@ test "sends approval emails when `approval_pending: true`" do
end
test "confirming a confirmed user does not trigger post-register actions" do
user = insert(:user, is_confirmed: true, approval_pending: true)
user = insert(:user, is_confirmed: true, is_approved: false)
User.confirm(user)
ObanHelpers.perform_all()
@ -1591,7 +1591,7 @@ test "deactivates user when activation is not required", %{user: user} do
end
test "delete/1 when approval is pending deletes the user" do
user = insert(:user, approval_pending: true)
user = insert(:user, is_approved: false)
{:ok, job} = User.delete(user)
{:ok, _} = ObanHelpers.perform(job)
@ -1618,7 +1618,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do
is_locked: true,
is_confirmed: false,
password_reset_pending: true,
approval_pending: true,
is_approved: false,
registration_reason: "ahhhhh",
confirmation_token: "qqqq",
domain_blocks: ["lain.com"],
@ -1660,7 +1660,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do
is_locked: false,
is_confirmed: true,
password_reset_pending: false,
approval_pending: false,
is_approved: true,
registration_reason: nil,
confirmation_token: nil,
domain_blocks: [],
@ -1755,10 +1755,10 @@ test "returns :deactivated for deactivated user" do
end
test "returns :approval_pending for unapproved user" do
user = insert(:user, local: true, approval_pending: true)
user = insert(:user, local: true, is_approved: false)
assert User.account_status(user) == :approval_pending
user = insert(:user, local: true, is_confirmed: false, approval_pending: true)
user = insert(:user, local: true, is_confirmed: false, is_approved: false)
assert User.account_status(user) == :approval_pending
end
end

View file

@ -429,7 +429,7 @@ test "allows to force-unfollow another user", %{admin: admin, conn: conn} do
describe "GET /api/pleroma/admin/users" do
test "renders users array for the first page", %{conn: conn, admin: admin} do
user = insert(:user, local: false, tags: ["foo", "bar"])
user2 = insert(:user, approval_pending: true, registration_reason: "I'm a chill dude")
user2 = insert(:user, is_approved: false, registration_reason: "I'm a chill dude")
conn = get(conn, "/api/pleroma/admin/users?page=1")
@ -444,7 +444,7 @@ test "renders users array for the first page", %{conn: conn, admin: admin} do
user2,
%{
"local" => true,
"approval_pending" => true,
"is_approved" => false,
"registration_reason" => "I'm a chill dude",
"actor_type" => "Person"
}
@ -638,7 +638,7 @@ test "only unconfirmed users", %{conn: conn} do
sad_user = insert(:user, nickname: "sadboy", is_confirmed: false)
old_user = insert(:user, nickname: "oldboy", is_confirmed: false)
insert(:user, nickname: "happyboy", approval_pending: false)
insert(:user, nickname: "happyboy", is_approved: true)
insert(:user, is_confirmed: true)
result =
@ -650,7 +650,7 @@ test "only unconfirmed users", %{conn: conn} do
Enum.map([old_user, sad_user], fn user ->
user_response(user, %{
"is_confirmed" => false,
"approval_pending" => false
"is_approved" => true
})
end)
|> Enum.sort_by(& &1["nickname"])
@ -662,18 +662,18 @@ test "only unapproved users", %{conn: conn} do
user =
insert(:user,
nickname: "sadboy",
approval_pending: true,
is_approved: false,
registration_reason: "Plz let me in!"
)
insert(:user, nickname: "happyboy", approval_pending: false)
insert(:user, nickname: "happyboy", is_approved: true)
conn = get(conn, "/api/pleroma/admin/users?filters=need_approval")
users = [
user_response(
user,
%{"approval_pending" => true, "registration_reason" => "Plz let me in!"}
%{"is_approved" => false, "registration_reason" => "Plz let me in!"}
)
]
@ -816,8 +816,8 @@ test "load users with tags list", %{conn: conn} do
end
test "`active` filters out users pending approval", %{token: token} do
insert(:user, approval_pending: true)
%{id: user_id} = insert(:user, approval_pending: false)
insert(:user, is_approved: false)
%{id: user_id} = insert(:user, is_approved: true)
%{id: admin_id} = token.user
conn =
@ -913,8 +913,8 @@ test "PATCH /api/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
end
test "PATCH /api/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
user_one = insert(:user, approval_pending: true)
user_two = insert(:user, approval_pending: true)
user_one = insert(:user, is_approved: false)
user_two = insert(:user, is_approved: false)
conn =
patch(
@ -924,7 +924,7 @@ test "PATCH /api/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
)
response = json_response(conn, 200)
assert Enum.map(response["users"], & &1["approval_pending"]) == [false, false]
assert Enum.map(response["users"], & &1["is_approved"]) == [true, true]
log_entry = Repo.one(ModerationLog)
@ -961,7 +961,7 @@ defp user_response(user, attrs \\ %{}) do
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
"display_name" => HTML.strip_tags(user.name || user.nickname),
"is_confirmed" => true,
"approval_pending" => false,
"is_approved" => true,
"url" => user.ap_id,
"registration_reason" => nil,
"actor_type" => "Person"

View file

@ -182,7 +182,7 @@ test "it returns user by email" do
end
test "it returns unapproved user" do
unapproved = insert(:user, approval_pending: true)
unapproved = insert(:user, is_approved: false)
insert(:user)
insert(:user)

View file

@ -1028,7 +1028,7 @@ test "registers and logs in without :account_activation_required / :account_appr
assert user
assert user.is_confirmed
refute user.approval_pending
assert user.is_approved
end
test "registers but does not log in with :account_activation_required", %{conn: conn} do
@ -1150,7 +1150,7 @@ test "registers but does not log in with :account_approval_required", %{conn: co
user = Repo.get_by(User, email: "lain@example.org")
assert user.approval_pending
refute user.is_approved
assert user.registration_reason == "I'm a cool dude, bro"
end

View file

@ -1041,7 +1041,7 @@ test "rejects token exchange for valid credentials belonging to an unapproved us
user =
insert(:user,
password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt(password),
approval_pending: true
is_approved: false
)
refute Pleroma.User.account_status(user) == :active

View file

@ -97,7 +97,7 @@ test "it sends an admin email if :account_approval_required is specified in inst
{:ok, user} = TwitterAPI.register_user(data)
ObanHelpers.perform_all()
assert user.approval_pending
refute user.is_approved
user_email = Pleroma.Emails.UserEmail.approval_pending_email(user)
admin_email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)