mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Move discourse-chat to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
This commit is contained in:
26
plugins/chat/app/models/concerns/chatable.rb
Normal file
26
plugins/chat/app/models/concerns/chatable.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Chatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def chat_channel
|
||||
channel_class.new(chatable: self)
|
||||
end
|
||||
|
||||
def create_chat_channel!(**args)
|
||||
channel_class.create!(args.merge(chatable: self))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def channel_class
|
||||
case self
|
||||
when Category
|
||||
CategoryChannel
|
||||
when DirectMessageChannel
|
||||
DMChannel
|
||||
else
|
||||
raise "Unknown chatable #{self}"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user