Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Dont use updater in action
Dieser Commit ist enthalten in:
Ursprung
f114672dd8
Commit
cda316a9c6
2 geänderte Dateien mit 4 neuen und 9 gelöschten Zeilen
|
@ -2,7 +2,6 @@ class CustomWizard::Action
|
||||||
attr_accessor :data,
|
attr_accessor :data,
|
||||||
:action,
|
:action,
|
||||||
:user,
|
:user,
|
||||||
:updater,
|
|
||||||
:result
|
:result
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
@ -10,7 +9,6 @@ class CustomWizard::Action
|
||||||
@action = params[:action]
|
@action = params[:action]
|
||||||
@user = params[:user]
|
@user = params[:user]
|
||||||
@data = params[:data]
|
@data = params[:data]
|
||||||
@updater = params[:updater]
|
|
||||||
@log = []
|
@log = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +45,6 @@ class CustomWizard::Action
|
||||||
if creator.errors.present?
|
if creator.errors.present?
|
||||||
messages = creator.errors.full_messages.join(" ")
|
messages = creator.errors.full_messages.join(" ")
|
||||||
log_error("failed to create", messages)
|
log_error("failed to create", messages)
|
||||||
updater.errors.add(:create_topic, messages)
|
|
||||||
elsif action['skip_redirect'].blank?
|
elsif action['skip_redirect'].blank?
|
||||||
data['redirect_on_complete'] = post.topic.url
|
data['redirect_on_complete'] = post.topic.url
|
||||||
end
|
end
|
||||||
|
@ -85,7 +82,6 @@ class CustomWizard::Action
|
||||||
if creator.errors.present?
|
if creator.errors.present?
|
||||||
messages = creator.errors.full_messages.join(" ")
|
messages = creator.errors.full_messages.join(" ")
|
||||||
log_error("failed to create message", messages)
|
log_error("failed to create message", messages)
|
||||||
updater.errors.add(:send_message, messages)
|
|
||||||
elsif action['skip_redirect'].blank?
|
elsif action['skip_redirect'].blank?
|
||||||
data['redirect_on_complete'] = post.topic.url
|
data['redirect_on_complete'] = post.topic.url
|
||||||
end
|
end
|
||||||
|
@ -123,7 +119,7 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
if result
|
if result
|
||||||
log_success("updated profile fields", "fields: #{params.keys.map{ |p| p.to_s }.join(',')}")
|
log_success("updated profile fields", "fields: #{params.keys.map(&:to_s).join(',')}")
|
||||||
else
|
else
|
||||||
log_error("failed to update profile fields", "result: #{result.inspect}")
|
log_error("failed to update profile fields", "result: #{result.inspect}")
|
||||||
end
|
end
|
||||||
|
@ -148,9 +144,9 @@ class CustomWizard::Action
|
||||||
|
|
||||||
if error = result['error'] || (result[0] && result[0]['error'])
|
if error = result['error'] || (result[0] && result[0]['error'])
|
||||||
error = error['message'] || error
|
error = error['message'] || error
|
||||||
updater.errors.add(:send_to_api, error)
|
log_error("api request failed", "message: #{error}")
|
||||||
else
|
else
|
||||||
## add validation callback
|
log_success("api request succeeded", "result: #{result}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -160,8 +160,7 @@ class CustomWizard::Builder
|
||||||
wizard: @wizard,
|
wizard: @wizard,
|
||||||
action: action,
|
action: action,
|
||||||
user: user,
|
user: user,
|
||||||
data: data,
|
data: data
|
||||||
updater: updater
|
|
||||||
).perform
|
).perform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren