2023-03-17 09:24:38 -04:00
|
|
|
# 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"
|
2023-03-21 23:24:07 -04:00
|
|
|
put "/channels/read/" => "reads#update_all"
|
|
|
|
put "/channels/:channel_id/read/:message_id" => "reads#update"
|
2023-11-28 12:24:09 -05:00
|
|
|
post "/channels/:channel_id/messages/:message_id/flags" => "channels_messages_flags#create"
|
2023-11-22 05:54:23 -05:00
|
|
|
post "/channels/:channel_id/drafts" => "channels_drafts#create"
|
2023-03-17 09:24:38 -04:00
|
|
|
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"
|
2023-07-27 03:57:03 -04:00
|
|
|
get "/channels/:channel_id/messages" => "channel_messages#index"
|
2023-10-23 04:40:30 -04:00
|
|
|
put "/channels/:channel_id/messages/:message_id" => "channel_messages#update"
|
2023-03-17 09:24:38 -04:00
|
|
|
post "/channels/:channel_id/messages/moves" => "channels_messages_moves#create"
|
2023-10-24 12:51:33 -04:00
|
|
|
post "/channels/:channel_id/invites" => "channels_invites#create"
|
2023-03-17 09:24:38 -04:00
|
|
|
post "/channels/:channel_id/archives" => "channels_archives#create"
|
|
|
|
get "/channels/:channel_id/memberships" => "channels_memberships#index"
|
2023-11-10 05:29:28 -05:00
|
|
|
post "/channels/:channel_id/memberships" => "channels_memberships#create"
|
2023-03-17 09:24:38 -04:00
|
|
|
delete "/channels/:channel_id/memberships/me" => "channels_current_user_membership#destroy"
|
2023-11-29 11:48:14 -05:00
|
|
|
delete "/channels/:channel_id/memberships/me/follows" =>
|
|
|
|
"channels_current_user_membership_follows#destroy"
|
|
|
|
put "/channels/:channel_id/memberships/me" => "channels_current_user_membership#update"
|
2023-03-17 09:24:38 -04:00
|
|
|
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
|
|
|
|
|
2023-05-10 05:42:32 -04:00
|
|
|
get "/channels/:channel_id/threads" => "channel_threads#index"
|
2023-09-15 12:09:45 -04:00
|
|
|
post "/channels/:channel_id/threads" => "channel_threads#create"
|
2023-05-10 05:42:32 -04:00
|
|
|
put "/channels/:channel_id/threads/:thread_id" => "channel_threads#update"
|
2023-03-17 09:24:38 -04:00
|
|
|
get "/channels/:channel_id/threads/:thread_id" => "channel_threads#show"
|
2023-07-27 03:57:03 -04:00
|
|
|
get "/channels/:channel_id/threads/:thread_id/messages" => "channel_thread_messages#index"
|
2023-05-04 11:28:51 -04:00
|
|
|
put "/channels/:channel_id/threads/:thread_id/read" => "thread_reads#update"
|
2023-11-22 05:54:23 -05:00
|
|
|
post "/channels/:channel_id/threads/:thread_id/drafts" => "channels_threads_drafts#create"
|
2023-06-15 22:08:26 -04:00
|
|
|
put "/channels/:channel_id/threads/:thread_id/notifications-settings/me" =>
|
|
|
|
"channel_threads_current_user_notifications_settings#update"
|
2023-04-03 19:30:38 -04:00
|
|
|
|
2023-07-02 20:18:37 -04:00
|
|
|
# TODO (martin) Remove this when we refactor the DM channel creation to happen
|
|
|
|
# via message creation in a different API controller.
|
|
|
|
post "/direct-message-channels" => "direct_messages#create"
|
|
|
|
|
2023-04-23 19:32:04 -04:00
|
|
|
put "/channels/:channel_id/messages/:message_id/restore" => "channel_messages#restore"
|
2023-04-03 19:30:38 -04:00
|
|
|
delete "/channels/:channel_id/messages/:message_id" => "channel_messages#destroy"
|
2023-06-13 13:21:46 -04:00
|
|
|
|
|
|
|
get "/channels/:channel_id/summarize" => "summaries#get_summary"
|
2023-03-17 09:24:38 -04:00
|
|
|
end
|
|
|
|
|
2023-06-21 08:13:36 -04:00
|
|
|
namespace :admin, defaults: { format: :json, constraints: StaffConstraint.new } do
|
|
|
|
post "export/messages" => "export#export_messages"
|
|
|
|
end
|
|
|
|
|
2023-03-17 09:24:38 -04:00
|
|
|
# direct_messages_controller routes
|
|
|
|
get "/direct_messages" => "direct_messages#index"
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
post "/dismiss-retention-reminder" => "chat#dismiss_retention_reminder"
|
|
|
|
put ":chat_channel_id/react/:message_id" => "chat#react"
|
|
|
|
put "/:chat_channel_id/:message_id/rebake" => "chat#rebake"
|
|
|
|
post "/:chat_channel_id/quote" => "chat#quote_messages"
|
|
|
|
put "/user_chat_enabled/:user_id" => "chat#set_user_chat_status"
|
2023-09-07 02:57:29 -04:00
|
|
|
post "/:chat_channel_id" => "api/channel_messages#create"
|
2023-11-28 12:24:09 -05:00
|
|
|
|
2023-03-17 09:24:38 -04:00
|
|
|
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"
|
2023-07-27 03:57:03 -04:00
|
|
|
get "#{base_c_route}/t/:thread_id/:message_id" => "chat#respond"
|
2023-03-17 09:24:38 -04:00
|
|
|
|
|
|
|
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
|