mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 07:37:55 +08:00
DEV: Move channel creation for category into service (#21167)
This commit moves the category channel creation out of the Chat::Api::Channel controller and into a dedicated CreateCategoryChannel service. A follow up commit will move the DM channel creation out of the old DirectMessageChannelCreator service. Also includes a new on_model_errors helper for chat service class usage, that collects model validation errors to present in a nice way. --------- Co-authored-by: Loïc Guitaut <loic@discourse.org>
This commit is contained in:
@ -84,6 +84,24 @@ module Chat
|
||||
def description
|
||||
"fail to find a model named '#{name}'"
|
||||
end
|
||||
|
||||
def step_failed?
|
||||
super && result[name].blank?
|
||||
end
|
||||
end
|
||||
|
||||
class FailWithInvalidModel < FailStep
|
||||
def type
|
||||
"model"
|
||||
end
|
||||
|
||||
def description
|
||||
"fail to have a valid model named '#{name}'"
|
||||
end
|
||||
|
||||
def step_failed?
|
||||
super && result[step].invalid
|
||||
end
|
||||
end
|
||||
|
||||
def fail_a_policy(name)
|
||||
@ -98,6 +116,10 @@ module Chat
|
||||
FailToFindModel.new(name)
|
||||
end
|
||||
|
||||
def fail_with_an_invalid_model(name = "model")
|
||||
FailWithInvalidModel.new(name)
|
||||
end
|
||||
|
||||
def inspect_steps(result)
|
||||
inspector = Chat::StepsInspector.new(result)
|
||||
puts "Steps:"
|
||||
|
Reference in New Issue
Block a user