diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb index 3965631bd5f213..a07f9a1d496d79 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/admin/accounts_controller.rb @@ -3,7 +3,7 @@ module Admin class AccountsController < BaseController before_action :set_account, except: [:index, :batch] - before_action :require_remote_account!, only: [:redownload] + before_action :require_remote_account!, only: [:redownload, :approve_remote, :reject_remote] before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject] def index @@ -66,6 +66,20 @@ def reject redirect_to admin_accounts_path(status: 'pending'), notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct) end + def approve_remote + authorize @account, :approve_remote? + @account.approve_remote! + log_action :approve_remote, @account + redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.approved_msg', username: @account.acct) + end + + def reject_remote + authorize @account, :reject_remote? + @account.reject_remote! + log_action :reject_remote, @account + redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct) + end + def destroy authorize @account, :destroy? Admin::AccountDeletionWorker.perform_async(@account.id) diff --git a/app/models/account.rb b/app/models/account.rb index b2e03a68596e13..f65575bff5a295 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -303,8 +303,7 @@ def approve_remote! end def reject_remote! - update!(remote_pending: false) - suspend! + update!(remote_pending: false, suspension_origin: :local) end def sensitized? diff --git a/app/views/admin/accounts/_buttons.html.haml b/app/views/admin/accounts/_buttons.html.haml index ff63709685cb7a..2063e93c7b5532 100644 --- a/app/views/admin/accounts/_buttons.html.haml +++ b/app/views/admin/accounts/_buttons.html.haml @@ -1,13 +1,18 @@ -- if account.suspended? +- if account.suspended? && !account.remote_pending %hr.spacer/ - if account.suspension_origin_remote? %p.muted-hint= deletion_request.present? ? t('admin.accounts.remote_suspension_reversible_hint_html', date: content_tag(:strong, l(deletion_request.due_at.to_date))) : t('admin.accounts.remote_suspension_irreversible') - else %p.muted-hint= deletion_request.present? ? t('admin.accounts.suspension_reversible_hint_html', date: content_tag(:strong, l(deletion_request.due_at.to_date))) : t('admin.accounts.suspension_irreversible') - = link_to t('admin.accounts.undo_suspension'), unsuspend_admin_account_path(account.id), method: :post, class: 'button' if can?(:unsuspend, account) && !account.remote_pending + = link_to t('admin.accounts.undo_suspension'), unsuspend_admin_account_path(account.id), method: :post, class: 'button' if can?(:unsuspend, account) = link_to t('admin.accounts.redownload'), redownload_admin_account_path(account.id), method: :post, class: 'button' if can?(:redownload, account) && account.suspension_origin_remote? - if deletion_request.present? && can?(:destroy, account) = link_to t('admin.accounts.delete'), admin_account_path(account.id), method: :delete, class: 'button button--destructive', data: { confirm: t('admin.accounts.are_you_sure') } +- elsif account.suspended? && account.remote_pending + %hr.spacer/ + %p.muted-hint= t('admin.accounts.remote_pending_hint_html') + = link_to t('admin.accounts.approve_remote'), approve_remote_admin_account_path(account.id), method: :post, class: 'button' if can?(:approve_remote, account) + = link_to t('admin.accounts.reject_remote'), reject_remote_admin_account_path(account.id), method: :post, class: 'button' if can?(:reject_remote, account) - else .action-buttons %div diff --git a/config/locales/en.yml b/config/locales/en.yml index 85ef990e3f2e9d..4e97f87c9538f1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,6 +34,7 @@ en: add_email_domain_block: Block e-mail domain approve: Approve approve_domain: Approve domain + approve_remote: Approve remote account approved_msg: Successfully approved %{username}'s sign-up application are_you_sure: Are you sure? avatar: Avatar @@ -118,7 +119,9 @@ en: redownload: Refresh profile redownloaded_msg: Successfully refreshed %{username}'s profile from origin reject: Reject + reject_remote: Reject remote account rejected_msg: Successfully rejected %{username}'s sign-up application + remote_pending_hint_html: This account is currently on hold and temporarily suspended. The account must be approved before it can be made available on this server. remote_suspension_irreversible: The data of this account has been irreversibly deleted. remote_suspension_reversible_hint_html: The account has been suspended on their server, and the data will be fully removed on %{date}. Until then, the remote server can restore this account without any ill effects. If you wish to remove all of the account's data immediately, you can do so below. remove_avatar: Remove avatar diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 325f905c81b9b7..f2d711ae58f459 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -32,6 +32,7 @@ ja: add_email_domain_block: メールドメインブロックに追加 approve: 承認 approve_domain: ドメインを承認 + approve_remote: リモートアカウントを承認 approved_msg: '%{username}さんの登録申請を承認しました' are_you_sure: 本当に実行しますか? avatar: アイコン @@ -115,7 +116,9 @@ ja: redownload: プロフィールを更新 redownloaded_msg: '%{username}のプロフィールを正常に更新しました' reject: 却下 + reject_remote: リモートアカウントを却下 rejected_msg: '%{username}さんの登録申請を却下しました' + remote_pending_hint_html: このアカウントは現在保留中で、一時的にサスペンド状態になっています。このサーバーで利用可能にするためには、アカウントを承認する必要があります。 remote_suspension_irreversible: このアカウントのデータは不可逆的に削除されました。 remote_suspension_reversible_hint_html: このアカウントは停止されており、データは%{date} 日で完全に削除されます。それまでは悪影響なしにアカウントを復旧させることができます。アカウントを即座に削除したい場合は、以下から行うことができます。 remove_avatar: アイコンを削除 diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 6c53ca79e620a6..7cf4f1d29c44f2 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -130,6 +130,8 @@ post :memorialize post :approve post :reject + post :approve_remote + post :reject_remote post :unblock_email end