From 455a3ee021c86729f85cf6329774ec2613518c1c Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Mon, 1 Jun 2026 20:59:52 +0530 Subject: [PATCH] feat(web): add Discord messaging channel setup --- surfsense_web/.env.example | 2 + .../components/MessagingChannelsContent.tsx | 50 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/surfsense_web/.env.example b/surfsense_web/.env.example index 032bb48ea..e4aaf91d7 100644 --- a/surfsense_web/.env.example +++ b/surfsense_web/.env.example @@ -12,6 +12,8 @@ NEXT_PUBLIC_ZERO_CACHE_URL=http://localhost:4848 NEXT_PUBLIC_GATEWAY_WHATSAPP_INTAKE_MODE=disabled # Slack gateway UI toggle: true or false NEXT_PUBLIC_GATEWAY_SLACK_ENABLED=false +# Discord gateway UI toggle: true or false +NEXT_PUBLIC_GATEWAY_DISCORD_ENABLED=false # Contact Form Vars (optional) DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.sdsf.supabase.co:5432/postgres diff --git a/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/MessagingChannelsContent.tsx b/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/MessagingChannelsContent.tsx index 57dfe321e..7d6f7cba6 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/MessagingChannelsContent.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/MessagingChannelsContent.tsx @@ -52,6 +52,7 @@ export function MessagingChannelsContent() { const searchSpaceId = Number(params.search_space_id); const whatsappMode = process.env.NEXT_PUBLIC_GATEWAY_WHATSAPP_INTAKE_MODE ?? "disabled"; const slackGatewayEnabled = process.env.NEXT_PUBLIC_GATEWAY_SLACK_ENABLED === "true"; + const discordGatewayEnabled = process.env.NEXT_PUBLIC_GATEWAY_DISCORD_ENABLED === "true"; const [bindings, setBindings] = useState([]); const [platforms, setPlatforms] = useState([]); const [pairing, setPairing] = useState(null); @@ -109,6 +110,17 @@ export function MessagingChannelsContent() { } } + async function installDiscordGateway() { + const res = await authenticatedFetch( + `${BACKEND_URL}/api/v1/gateway/discord/install?search_space_id=${searchSpaceId}` + ); + if (!res.ok) return; + const data = (await res.json()) as { auth_url?: string }; + if (data.auth_url) { + window.location.href = data.auth_url; + } + } + function refreshBaileys() { startTransition(async () => { await refreshBaileysHealth(); @@ -133,11 +145,13 @@ export function MessagingChannelsContent() { const telegram = platforms.find((p) => p.platform === "telegram"); const whatsapp = platforms.find((p) => p.platform === "whatsapp"); const slack = platforms.find((p) => p.platform === "slack"); + const discord = platforms.find((p) => p.platform === "discord"); const baileysQr = baileysHealth?.qr || null; const activeBindings = bindings.filter( (binding) => binding.search_space_id === searchSpaceId && - binding.external_metadata?.kind !== "slack_thread" + binding.external_metadata?.kind !== "slack_thread" && + binding.external_metadata?.kind !== "discord_thread" ); const renderPairingPanel = (platform: PairingPlatform) => { if (!pairing || pairingPlatform !== platform) return null; @@ -222,6 +236,40 @@ export function MessagingChannelsContent() { ) : null} + {discordGatewayEnabled ? ( + + +
+ + + Discord Bot + + + {discord ? "enabled" : "not enabled"} + +
+

+ Enable the SurfSense Discord bot so teammates can mention it in Discord. This is + separate from the Discord connector. +

+
+ +
+ + +
+

+ Discord search remains controlled by the Discord connector in the connector popup. +

+
+
+ ) : null} + {whatsappMode !== "disabled" ? (