2015-03-31 12:58:56 -04:00
|
|
|
require_dependency 'has_errors'
|
|
|
|
|
|
|
|
class NewPostResult
|
|
|
|
include HasErrors
|
|
|
|
|
|
|
|
attr_reader :action
|
2015-04-28 15:06:27 -04:00
|
|
|
|
|
|
|
attr_accessor :reason
|
2015-03-31 12:58:56 -04:00
|
|
|
attr_accessor :post
|
2019-01-03 12:03:01 -05:00
|
|
|
attr_accessor :reviewable
|
2015-04-24 15:44:59 -04:00
|
|
|
attr_accessor :pending_count
|
2015-03-31 12:58:56 -04:00
|
|
|
|
2017-07-27 21:20:09 -04:00
|
|
|
def initialize(action, success = false)
|
2015-03-31 12:58:56 -04:00
|
|
|
@action = action
|
|
|
|
@success = success
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_errors_from(obj)
|
|
|
|
if obj.errors.empty?
|
|
|
|
@success = true
|
|
|
|
else
|
|
|
|
add_errors_from(obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
def check_errors(arr)
|
|
|
|
if arr.empty?
|
|
|
|
@success = true
|
|
|
|
else
|
|
|
|
arr.each { |e| errors[:base] << e unless errors[:base].include?(e) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def queued_post
|
|
|
|
Discourse.deprecate(
|
|
|
|
"NewPostManager#queued_post is deprecated. Please use #reviewable instead.",
|
|
|
|
output_in_test: true
|
|
|
|
)
|
|
|
|
|
|
|
|
reviewable
|
|
|
|
end
|
|
|
|
|
2015-03-31 12:58:56 -04:00
|
|
|
def success?
|
|
|
|
@success
|
|
|
|
end
|
|
|
|
|
|
|
|
def failed?
|
|
|
|
!@success
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|