From c138fc68d0d78f6cab2eb36467635af6d6fd44c6 Mon Sep 17 00:00:00 2001 From: ansible user/allowed to read system logs Date: Thu, 3 Aug 2023 19:42:05 -0700 Subject: [PATCH] discord is working --- README.md | 4 +- client/public/index.html | 2 +- client/src/api/discord.ts | 8 ++ client/src/components/join/joinChannel.tsx | 17 ++- .../src/components/platforms/discordLogin.tsx | 2 +- example.env | 4 + server/config/custom-environment-variables.ts | 7 +- server/src/controllers/discord.controller.ts | 128 +++++++++++++++++- server/src/controllers/slack.controller.ts | 2 + server/src/entities/bridge.entity.ts | 37 ++++- server/src/entities/channel.entity.ts | 4 +- server/src/matterbridge/config.ts | 111 +++++++++++---- server/src/matterbridge/process.ts | 13 +- server/src/routes/discord.routes.ts | 6 +- server/src/schemas/discord.schema.ts | 14 ++ server/src/types/config.ts | 1 + 16 files changed, 311 insertions(+), 49 deletions(-) create mode 100644 server/src/schemas/discord.schema.ts diff --git a/README.md b/README.md index 27414fa..31a5d83 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ Very unfinished!! Mostly a programming exercise for me for now to practice fulls ## TODO -- [ ] Manage matterbridge processes +- [x] Manage matterbridge processes - [ ] Sanitize user inputs - [ ] Check status of matterbridge processes -- [ ] Complete slack login workflow +- [x] Complete slack login workflow - [ ] Kill group processes & delete config when group is deleted ## Supported Clients diff --git a/client/public/index.html b/client/public/index.html index ffb4d68..7744282 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - ChatBridge2 + ChatBridge diff --git a/client/src/api/discord.ts b/client/src/api/discord.ts index d2b521a..0f20608 100644 --- a/client/src/api/discord.ts +++ b/client/src/api/discord.ts @@ -4,4 +4,12 @@ export const getDiscordInstallURL = (callback: CallableFunction) => { .then(res => { callback(res.data.url) }) +} + +export const getDiscordChannels = (callback: CallableFunction) => { + fetch('api/discord/channels') + .then(res => res.json()) + .then(res => { + callback(res.data.channels) + }) } \ No newline at end of file diff --git a/client/src/components/join/joinChannel.tsx b/client/src/components/join/joinChannel.tsx index 8f1416c..a858880 100644 --- a/client/src/components/join/joinChannel.tsx +++ b/client/src/components/join/joinChannel.tsx @@ -9,6 +9,7 @@ import {getSlackChannels, joinSlackChannel} from "../../api/slack"; import {useEffect, useState} from "react"; import {channelsType} from "../../types/channel"; import {bridgeType} from "../../types/bridge"; +import {getDiscordChannels} from "../../api/discord"; export interface JoinChannelProps { @@ -37,6 +38,10 @@ const JoinChannel = ({ switch(platform){ case "Slack": getSlackChannels(setChannels) + break + case "Discord": + getDiscordChannels(setChannels) + break } } }, [platform, bridge]) @@ -51,7 +56,13 @@ const JoinChannel = ({ } const onChannelChanged = (evt:any) => { - setStepComplete({...stepComplete, channel:false}) + if (platform === "Discord"){ + // Discord bots are in all channels by default - selecting one here completes the step + setStepComplete({...stepComplete, channel:true}) + } else { + // Otherwise, we need to do something to join the channel, so selecting means we have yet to join it. + setStepComplete({...stepComplete, channel: false}) + } setSelectedChannel(evt.target.value) } @@ -67,7 +78,7 @@ const JoinChannel = ({ return (
- + Select Channel