about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-12-10 01:26:00 -0600
committermultiple creatures <dev@multiple-creature.party>2019-12-10 02:36:38 -0600
commit5af281b0578c0752a1d08ebd697719387aee7e6e (patch)
tree661ca8f023c09cd7435bf2ee1e457e336a2fa961 /app
parent882d089dd0d863ac6ca81b75b78472683b533420 (diff)
add synchronize button to account manager
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/accounts_controller.rb14
-rw-r--r--app/policies/account_policy.rb6
-rw-r--r--app/views/admin/accounts/show.html.haml1
3 files changed, 18 insertions, 3 deletions
diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb
index a62eb6477..f74082562 100644
--- a/app/controllers/admin/accounts_controller.rb
+++ b/app/controllers/admin/accounts_controller.rb
@@ -2,8 +2,8 @@
 
 module Admin
   class AccountsController < BaseController
-    before_action :set_account, only: [:show, :redownload, :remove_avatar, :remove_header, :enable, :mark_known, :mark_unknown, :allow_public, :allow_nonsensitive, :unsilence, :unsuspend, :memorialize, :approve, :reject]
-    before_action :require_remote_account!, only: [:redownload]
+    before_action :set_account, only: [:show, :redownload, :remove_avatar, :remove_header, :enable, :mark_known, :mark_unknown, :allow_public, :allow_nonsensitive, :unsilence, :unsuspend, :memorialize, :approve, :reject, :sync]
+    before_action :require_remote_account!, only: [:redownload, :sync]
     before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
 
     def index
@@ -110,6 +110,16 @@ module Admin
       redirect_to admin_account_path(@account.id)
     end
 
+    def sync
+      authorize @account, :sync?
+
+      @account.update!(last_webfingered_at: nil)
+      ResolveAccountService.new.call(@account)
+      SyncRemoteAccountWorker.perform_async(@account.id)
+
+      redirect_to admin_account_path(@account.id)
+    end
+
     def remove_avatar
       authorize @account, :remove_avatar?
 
diff --git a/app/policies/account_policy.rb b/app/policies/account_policy.rb
index 35f9b98b3..21e6e6132 100644
--- a/app/policies/account_policy.rb
+++ b/app/policies/account_policy.rb
@@ -54,7 +54,11 @@ class AccountPolicy < ApplicationPolicy
   end
 
   def redownload?
-    admin?
+    staff?
+  end
+
+  def sync?
+    staff?
   end
 
   def remove_avatar?
diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml
index f89b72422..a6e9d4446 100644
--- a/app/views/admin/accounts/show.html.haml
+++ b/app/views/admin/accounts/show.html.haml
@@ -191,6 +191,7 @@
         = link_to t('admin.accounts.memorialize'), memorialize_admin_account_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button button--destructive' if can?(:memorialize, @account)
     - else
       = link_to t('admin.accounts.redownload'), redownload_admin_account_path(@account.id), method: :post, class: 'button' if can?(:redownload, @account)
+      = link_to t('admin.accounts.sync'), sync_admin_account_path(@account.id), method: :post, class: 'button' if can?(:sync, @account)
 
   %hr.spacer/