Add Discord event announcement functionality to backend
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / compose (push) Has been cancelled

This commit introduces a new Discord event announcer to the backend, allowing for event announcements via Discord. It includes the addition of new environment variables for Discord configuration in `.env.example` and `compose.yaml`. The `main.go` file has been updated to initialize the announcer, and a new `discord` package has been created, containing the announcer logic and tests. Additionally, the service layer has been modified to support bracket draft management, enhancing the overall event workflow. Integration tests have been updated to ensure proper functionality of the new features.
This commit is contained in:
2026-07-19 11:21:11 +03:00
parent b7a78b4384
commit ae19c03542
31 changed files with 1632 additions and 88 deletions

View File

@@ -11,6 +11,7 @@ import (
"syscall"
"time"
discordadapter "mixmaker/backend/internal/adapter/discord"
"mixmaker/backend/internal/adapter/httpapi"
"mixmaker/backend/internal/adapter/postgres"
"mixmaker/backend/internal/application"
@@ -37,7 +38,22 @@ func main() {
}
defer store.Close()
hub := realtime.New()
service := application.New(store, hub)
var eventAnnouncer application.EventAnnouncer
discordBotToken := os.Getenv("DISCORD_BOT_TOKEN")
discordAnnouncementChannelID := os.Getenv("DISCORD_ANNOUNCEMENT_CHANNEL_ID")
if discordBotToken != "" || discordAnnouncementChannelID != "" {
eventAnnouncer, err = discordadapter.New(discordadapter.Config{
BotToken: discordBotToken,
ChannelID: discordAnnouncementChannelID,
PublicURL: env("PUBLIC_URL", env("FRONTEND_URL", "")),
Locale: env("DISCORD_ANNOUNCEMENT_LOCALE", "ru"),
})
if err != nil {
slog.Error("Discord announcer configuration failed", "error", err)
os.Exit(2)
}
}
service := application.New(store, hub, eventAnnouncer)
cfg := httpapi.Config{
DiscordClientID: required("DISCORD_CLIENT_ID"),
DiscordClientSecret: required("DISCORD_CLIENT_SECRET"),