FEATURE: Allow discourse script to skip disabling of emails after restore
This commit is contained in:
parent
ccff1d2dbb
commit
78f8114989
|
@ -29,6 +29,7 @@ module BackupRestore
|
|||
@client_id = opts[:client_id]
|
||||
@filename = opts[:filename]
|
||||
@publish_to_message_bus = opts[:publish_to_message_bus] || false
|
||||
@disable_emails = opts.fetch(:disable_emails, true)
|
||||
|
||||
ensure_restore_is_enabled
|
||||
ensure_no_operation_is_running
|
||||
|
@ -402,9 +403,11 @@ module BackupRestore
|
|||
log "Reloading site settings..."
|
||||
SiteSetting.refresh!
|
||||
|
||||
log "Disabling outgoing emails for non-staff users..."
|
||||
user = User.find_by_email(@user_info[:email]) || Discourse.system_user
|
||||
SiteSetting.set_and_log(:disable_emails, 'non-staff', user)
|
||||
if @disable_emails
|
||||
log "Disabling outgoing emails for non-staff users..."
|
||||
user = User.find_by_email(@user_info[:email]) || Discourse.system_user
|
||||
SiteSetting.set_and_log(:disable_emails, 'non-staff', user)
|
||||
end
|
||||
end
|
||||
|
||||
def clear_emoji_cache
|
||||
|
|
|
@ -106,6 +106,7 @@ class DiscourseCLI < Thor
|
|||
end
|
||||
|
||||
desc "restore", "Restore a Discourse backup"
|
||||
option :disable_emails, type: :boolean, default: true
|
||||
def restore(filename = nil)
|
||||
|
||||
if File.exist?('/usr/local/bin/discourse')
|
||||
|
@ -132,7 +133,11 @@ class DiscourseCLI < Thor
|
|||
|
||||
begin
|
||||
puts "Starting restore: #{filename}"
|
||||
restorer = BackupRestore::Restorer.new(Discourse.system_user.id, filename: filename)
|
||||
restorer = BackupRestore::Restorer.new(
|
||||
Discourse.system_user.id,
|
||||
filename: filename,
|
||||
disable_emails: options[:disable_emails]
|
||||
)
|
||||
restorer.run
|
||||
puts 'Restore done.'
|
||||
rescue BackupRestore::FilenameMissingError
|
||||
|
|
Loading…
Reference in New Issue