mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:12:40 +08:00
FIX: correctly load channels in chat webhooks
In 4e7a75a7ece3205ce9f3f188b5e016bf75a869c0, we moved to a single admin plugin page and added a few fields to the "plugin serializer" but we already had a proper route with the correct serializers to properly load channels. This fixes it by removing the "add_to_serializer" calls and changed the calls to "/admin/plugins/chat.json" to the proper "/admin/plugins/chat/hooks.json" route. Meta - https://meta.discourse.org/t/names-are-missing-from-list-when-creating-new-chat-channel-webhooks/308481
This commit is contained in:
@ -131,16 +131,6 @@ after_initialize do
|
||||
end
|
||||
end
|
||||
|
||||
add_to_serializer(
|
||||
:admin_plugin,
|
||||
:incoming_chat_webhooks,
|
||||
include_condition: -> { self.name == "chat" },
|
||||
) { Chat::IncomingWebhook.includes(:chat_channel).all }
|
||||
|
||||
add_to_serializer(:admin_plugin, :chat_channels, include_condition: -> { self.name == "chat" }) do
|
||||
Chat::Channel.public_channels
|
||||
end
|
||||
|
||||
add_to_serializer(:user_card, :can_chat_user) do
|
||||
return false if !SiteSetting.chat_enabled
|
||||
return false if scope.user.blank? || scope.user.id == object.id
|
||||
@ -443,7 +433,7 @@ after_initialize do
|
||||
Discourse::Application.routes.append do
|
||||
mount ::Chat::Engine, at: "/chat"
|
||||
|
||||
get "/admin/plugins/chat" => "chat/admin/incoming_webhooks#index",
|
||||
get "/admin/plugins/chat/hooks" => "chat/admin/incoming_webhooks#index",
|
||||
:constraints => StaffConstraint.new
|
||||
post "/admin/plugins/chat/hooks" => "chat/admin/incoming_webhooks#create",
|
||||
:constraints => StaffConstraint.new
|
||||
|
Reference in New Issue
Block a user