mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 15:52:45 +08:00
12a18d4d55
This commit main goal was to comply with Zeitwerk and properly rely on autoloading. To achieve this, most resources have been namespaced under the `Chat` module. - Given all models are now namespaced with `Chat::` and would change the stored types in DB when using polymorphism or STI (single table inheritance), this commit uses various Rails methods to ensure proper class is loaded and the stored name in DB is unchanged, eg: `Chat::Message` model will be stored as `"ChatMessage"`, and `"ChatMessage"` will correctly load `Chat::Message` model. - Jobs are now using constants only, eg: `Jobs::Chat::Foo` and should only be enqueued this way Notes: - This commit also used this opportunity to limit the number of registered css files in plugin.rb - `discourse_dev` support has been removed within this commit and will be reintroduced later <!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
93 lines
4.0 KiB
Ruby
93 lines
4.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
Chat::Engine.routes.draw do
|
|
namespace :api, defaults: { format: :json } do
|
|
get "/chatables" => "chatables#index"
|
|
get "/channels" => "channels#index"
|
|
get "/channels/me" => "current_user_channels#index"
|
|
post "/channels" => "channels#create"
|
|
delete "/channels/:channel_id" => "channels#destroy"
|
|
put "/channels/:channel_id" => "channels#update"
|
|
get "/channels/:channel_id" => "channels#show"
|
|
put "/channels/:channel_id/status" => "channels_status#update"
|
|
post "/channels/:channel_id/messages/moves" => "channels_messages_moves#create"
|
|
post "/channels/:channel_id/archives" => "channels_archives#create"
|
|
get "/channels/:channel_id/memberships" => "channels_memberships#index"
|
|
delete "/channels/:channel_id/memberships/me" => "channels_current_user_membership#destroy"
|
|
post "/channels/:channel_id/memberships/me" => "channels_current_user_membership#create"
|
|
put "/channels/:channel_id/notifications-settings/me" =>
|
|
"channels_current_user_notifications_settings#update"
|
|
|
|
# Category chatables controller hints. Only used by staff members, we don't want to leak category permissions.
|
|
get "/category-chatables/:id/permissions" => "category_chatables#permissions",
|
|
:format => :json,
|
|
:constraints => StaffConstraint.new
|
|
|
|
# Hints for JIT warnings.
|
|
get "/mentions/groups" => "hints#check_group_mentions", :format => :json
|
|
|
|
get "/channels/:channel_id/threads/:thread_id" => "channel_threads#show"
|
|
end
|
|
|
|
# direct_messages_controller routes
|
|
get "/direct_messages" => "direct_messages#index"
|
|
post "/direct_messages/create" => "direct_messages#create"
|
|
|
|
# incoming_webhooks_controller routes
|
|
post "/hooks/:key" => "incoming_webhooks#create_message"
|
|
|
|
# incoming_webhooks_controller routes
|
|
post "/hooks/:key/slack" => "incoming_webhooks#create_message_slack_compatible"
|
|
|
|
# chat_controller routes
|
|
get "/" => "chat#respond"
|
|
get "/browse" => "chat#respond"
|
|
get "/browse/all" => "chat#respond"
|
|
get "/browse/closed" => "chat#respond"
|
|
get "/browse/open" => "chat#respond"
|
|
get "/browse/archived" => "chat#respond"
|
|
get "/draft-channel" => "chat#respond"
|
|
post "/enable" => "chat#enable_chat"
|
|
post "/disable" => "chat#disable_chat"
|
|
post "/dismiss-retention-reminder" => "chat#dismiss_retention_reminder"
|
|
get "/:chat_channel_id/messages" => "chat#messages"
|
|
get "/message/:message_id" => "chat#message_link"
|
|
put ":chat_channel_id/edit/:message_id" => "chat#edit_message"
|
|
put ":chat_channel_id/react/:message_id" => "chat#react"
|
|
delete "/:chat_channel_id/:message_id" => "chat#delete"
|
|
put "/:chat_channel_id/:message_id/rebake" => "chat#rebake"
|
|
post "/:chat_channel_id/:message_id/flag" => "chat#flag"
|
|
post "/:chat_channel_id/quote" => "chat#quote_messages"
|
|
put "/:chat_channel_id/restore/:message_id" => "chat#restore"
|
|
get "/lookup/:message_id" => "chat#lookup_message"
|
|
put "/:chat_channel_id/read/:message_id" => "chat#update_user_last_read"
|
|
put "/user_chat_enabled/:user_id" => "chat#set_user_chat_status"
|
|
put "/:chat_channel_id/invite" => "chat#invite_users"
|
|
post "/drafts" => "chat#set_draft"
|
|
post "/:chat_channel_id" => "chat#create_message"
|
|
put "/flag" => "chat#flag"
|
|
get "/emojis" => "emojis#index"
|
|
|
|
base_c_route = "/c/:channel_title/:channel_id"
|
|
get base_c_route => "chat#respond", :as => "channel"
|
|
get "#{base_c_route}/:message_id" => "chat#respond"
|
|
|
|
%w[info info/about info/members info/settings].each do |route|
|
|
get "#{base_c_route}/#{route}" => "chat#respond"
|
|
end
|
|
|
|
# /channel -> /c redirects
|
|
get "/channel/:channel_id", to: redirect("/chat/c/-/%{channel_id}")
|
|
|
|
get "#{base_c_route}/t/:thread_id" => "chat#respond"
|
|
|
|
base_channel_route = "/channel/:channel_id/:channel_title"
|
|
redirect_base = "/chat/c/%{channel_title}/%{channel_id}"
|
|
|
|
get base_channel_route, to: redirect(redirect_base)
|
|
|
|
%w[info info/about info/members info/settings].each do |route|
|
|
get "#{base_channel_route}/#{route}", to: redirect("#{redirect_base}/#{route}")
|
|
end
|
|
end
|