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:
Martin Brennan
2023-04-24 09:15:16 +10:00
committed by GitHub
parent f0bdb2ee9a
commit 21f93731a3
12 changed files with 345 additions and 54 deletions

View File

@ -12,6 +12,10 @@ module Chat
channel_class.create!(args.merge(chatable: self))
end
def create_chat_channel(**args)
channel_class.create(args.merge(chatable: self))
end
private
def channel_class