diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 19f5ceb85..4dde6d852 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -58,9 +58,9 @@ module Admin
def full_delete
@user = User.find(params[:id])
begin
- Moderator::DeleteUser.call(admin: current_user, user: @user, user_params: user_params)
+ Moderator::DeleteUser.call(user: @user)
message = "@#{@user.username} (email: #{@user.email.presence || 'no email'}, user_id: #{@user.id}) " \
- "has been fully deleted. If requested, old content may have been ghostified. " \
+ "has been fully deleted." \
"If this is a GDPR delete, delete them from Mailchimp & Google Analytics."
flash[:success] = message
rescue StandardError => e
@@ -186,7 +186,7 @@ module Admin
allowed_params = %i[
new_note note_for_current_role user_status
pro merge_user_id add_credits remove_credits
- add_org_credits remove_org_credits ghostify
+ add_org_credits remove_org_credits
organization_id identity_id backup_data_id
]
params.require(:user).permit(allowed_params)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 50f8fbbaa..6fff81473 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -266,8 +266,6 @@ class UsersController < ApplicationController
handle_integrations_tab
when "billing"
handle_billing_tab
- when "account"
- handle_account_tab
when "response-templates"
handle_response_templates_tab
else
@@ -335,17 +333,6 @@ class UsersController < ApplicationController
@customer = Payments::Customer.get(stripe_code) if stripe_code.present?
end
- def handle_account_tab
- community_name = SiteConfig.community_name
- @email_body = <<~HEREDOC
- Hello #{community_name} Team,\n
- I would like to delete my account.\n
- You can keep any comments and discussion posts under the Ghost account.\n
- Regards,
- YOUR-#{community_name}-USERNAME-HERE
- HEREDOC
- end
-
def handle_response_templates_tab
@response_templates = current_user.response_templates
@response_template = ResponseTemplate.find_or_initialize_by(id: params[:id], user: current_user)
diff --git a/app/models/user.rb b/app/models/user.rb
index 4e5682804..b0c040f9e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -92,8 +92,7 @@ class User < ApplicationRecord
}.freeze
attr_accessor :scholar_email, :new_note, :note_for_current_role, :user_status, :pro, :merge_user_id,
- :add_credits, :remove_credits, :add_org_credits, :remove_org_credits, :ghostify,
- :ip_address
+ :add_credits, :remove_credits, :add_org_credits, :remove_org_credits, :ip_address
rolify after_add: :index_roles, after_remove: :index_roles
diff --git a/app/services/moderator/delete_user.rb b/app/services/moderator/delete_user.rb
index a760bde9d..f6f5e1ca4 100644
--- a/app/services/moderator/delete_user.rb
+++ b/app/services/moderator/delete_user.rb
@@ -1,21 +1,9 @@
module Moderator
class DeleteUser < ManageActivityAndRoles
- attr_reader :user, :admin, :user_params
+ attr_reader :user, :user_params
- def self.call(admin:, user:, user_params:)
- if user_params[:ghostify] == "true"
- new(user: user, admin: admin, user_params: user_params).ghostify
- else
- Users::DeleteWorker.perform_async(user.id, true)
- end
- end
-
- def ghostify
- @ghost = User.find_by(username: "ghost")
- reassign_articles
- reassign_comments
- delete_user
- CacheBuster.bust("/ghost")
+ def self.call(user:)
+ Users::DeleteWorker.perform_async(user.id, true)
end
private
@@ -23,25 +11,5 @@ module Moderator
def delete_user
Users::DeleteWorker.new.perform(user.id, true)
end
-
- def reassign_comments
- return unless user.comments.any?
-
- user.comments.find_each do |comment|
- comment.update(user_id: @ghost.id)
- end
- @ghost.touch(:last_comment_at)
- end
-
- def reassign_articles
- return unless user.articles.any?
-
- # preload associations that are going to be used during indexing
- user.articles.preload(:organization, :tag_taggings, :tags).find_each do |article|
- path = "/#{@ghost.username}/#{article.slug}"
- article.update_columns(user_id: @ghost.id, path: path)
- article.index_to_elasticsearch_inline
- end
- end
end
end
diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb
index 5956f2890..a46c0adb4 100644
--- a/app/views/admin/users/edit.html.erb
+++ b/app/views/admin/users/edit.html.erb
@@ -147,18 +147,6 @@
<% if current_user.has_role?(:super_admin) %>
-
-
Delete User & Turn Content Into Ghost
-
This will
- completely destroy the user and convert all of their articles & comments into a ghost author. This action is irreversible.
-
-
Do not do this lightly.
- <%= form_for(@user, url: full_delete_admin_user_path(@user), html: { method: :post, onsubmit: "return confirm('Are you sure? 👻 This is extremely destructive and irreversible. The user will be deleted and their articles & comments will be converted to Ghost')" }) do |f| %>
- <%= f.hidden_field :ghostify, value: true %>
-
- <% end %>
-
-
Fully Delete User
This will
@@ -166,7 +154,6 @@
Do not do this lightly.
<%= form_for(@user, url: full_delete_admin_user_path(@user), html: { method: :post, onsubmit: "return confirm('Are you sure? This is extremely destructive and irreversible.')" }) do |f| %>
- <%= f.hidden_field :ghostify, value: false %>
<% end %>
- <% if current_user.articles_count.positive? || current_user.comments_count.positive? %>
-
- If you would like to keep your content under the <%= link_to "@ghost", "/ghost" %> account,
- please <%= email_link(text: "click here", additional_info: { subject: "Request Account Deletion", body: @email_body }) %>.
-
- <% end %>
-
Feel free to contact <%= email_link %> with any questions.
diff --git a/spec/requests/admin/users_manage_spec.rb b/spec/requests/admin/users_manage_spec.rb
index 02013bf23..5b53249c2 100644
--- a/spec/requests/admin/users_manage_spec.rb
+++ b/spec/requests/admin/users_manage_spec.rb
@@ -8,7 +8,6 @@ RSpec.describe "Admin::Users", type: :request do
let(:article) { create(:article, user: user) }
let(:article2) { create(:article, user: user2) }
let(:badge) { create(:badge, title: "one-year-club") }
- let(:ghost) { create(:user, username: "ghost", github_username: "Ghost") }
let(:organization) { create(:organization) }
before do
@@ -62,11 +61,6 @@ RSpec.describe "Admin::Users", type: :request do
GithubRepo.create(params)
end
- def call_ghost
- ghost
- post "/admin/users/#{user.id}/full_delete", params: { user: { ghostify: "true" } }
- end
-
context "when merging users" do
before do
full_profile
@@ -170,25 +164,6 @@ RSpec.describe "Admin::Users", type: :request do
expect(user.credits.size).to eq(2)
end
end
-
-
- context "when deleting user and converting content to ghost" do
- it "raises a 'record not found' error after deletion" do
- call_ghost
- expect { User.find(user.id) }.to raise_exception(ActiveRecord::RecordNotFound)
- end
-
- it "reassigns comment and article content to ghost account" do
- create(:article, user: user)
- call_ghost
- articles = ghost.articles
- expect(articles.count).to eq(2)
- expect(ghost.comments.count).to eq(1)
- expect(ghost.comments.last.path).to include("ghost")
- expect(articles.last.path).to include("ghost")
- expect(articles.last.elasticsearch_doc.dig("_source", "path")).to include("ghost")
- end
- end
context "when deleting user" do
def create_mention
@@ -217,13 +192,13 @@ RSpec.describe "Admin::Users", type: :request do
it "raises a 'record not found' error after deletion" do
sidekiq_perform_enqueued_jobs do
- post "/admin/users/#{user.id}/full_delete", params: { user: { ghostify: "false" } }
+ post "/admin/users/#{user.id}/full_delete"
end
expect { User.find(user.id) }.to raise_exception(ActiveRecord::RecordNotFound)
end
it "expect flash message" do
- post "/admin/users/#{user.id}/full_delete", params: { user: { ghostify: "false" } }
+ post "/admin/users/#{user.id}/full_delete"
expect(request.flash["success"]).to include("fully deleted")
end
end
diff --git a/spec/requests/user/user_settings_spec.rb b/spec/requests/user/user_settings_spec.rb
index 9aef0e967..9bb2ad7fd 100644
--- a/spec/requests/user/user_settings_spec.rb
+++ b/spec/requests/user/user_settings_spec.rb
@@ -56,7 +56,6 @@ RSpec.describe "UserSettings", type: :request do
end
describe ":account" do
- let(:ghost_account_message) { "If you would like to keep your content under the" }
let(:remove_oauth_section) { "Remove OAuth Associations" }
let(:user) { create(:user, :with_identity) }
@@ -70,20 +69,6 @@ RSpec.describe "UserSettings", type: :request do
expect(response).to have_http_status(:ok)
end
- it "does not render the ghost account email option if the user has no content" do
- get user_settings_path(tab: "account")
- expect(response.body).not_to include(ghost_account_message)
- end
-
- it "does render the ghost account email option if the user has content" do
- create(:article, user: user)
- user.update(articles_count: 1)
-
- get user_settings_path(tab: "account")
-
- expect(response.body).to include(ghost_account_message)
- end
-
it "shows the 'Remove OAuth' section if a user has multiple enabled identities" do
allow(Authentication::Providers).to receive(:enabled).and_return(Authentication::Providers.available)
providers = Authentication::Providers.available.first(2)
diff --git a/spec/services/moderator/delete_user_spec.rb b/spec/services/moderator/delete_user_spec.rb
index f4373ede4..bb70993ac 100644
--- a/spec/services/moderator/delete_user_spec.rb
+++ b/spec/services/moderator/delete_user_spec.rb
@@ -2,12 +2,11 @@ require "rails_helper"
RSpec.describe Moderator::DeleteUser, type: :service do
let(:user) { create(:user) }
- let(:admin) { create(:user, :super_admin) }
describe "delete_user" do
it "deletes user" do
sidekiq_perform_enqueued_jobs do
- described_class.call(user: user, admin: admin, user_params: {})
+ described_class.call(user: user)
end
expect(User.find_by(id: user.id)).to be_nil
end
@@ -18,7 +17,7 @@ RSpec.describe Moderator::DeleteUser, type: :service do
expect do
sidekiq_perform_enqueued_jobs do
- described_class.call(user: user, admin: admin, user_params: {})
+ described_class.call(user: user)
end
end.to change(Follow, :count).by(-2)
end
@@ -26,30 +25,9 @@ RSpec.describe Moderator::DeleteUser, type: :service do
it "deletes user's articles" do
article = create(:article, user: user)
sidekiq_perform_enqueued_jobs do
- described_class.call(user: user, admin: admin, user_params: {})
+ described_class.call(user: user)
end
expect(Article.find_by(id: article.id)).to be_nil
end
end
-
- describe "#ghostify" do
- let(:deleter) { described_class.new(user: user, admin: admin, user_params: { ghostify: true }) }
-
- before do
- user.update(username: "ghost")
- create(:article, user: user)
- end
-
- it "reassigns articles" do
- allow(deleter).to receive(:reassign_articles)
- deleter.ghostify
- expect(deleter).to have_received(:reassign_articles)
- end
-
- it "reassigns comments" do
- allow(deleter).to receive(:reassign_comments)
- deleter.ghostify
- expect(deleter).to have_received(:reassign_comments)
- end
- end
end