Add Discord guild ID configuration and enhance event announcement options
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / compose (push) Has been cancelled

This commit introduces the `DISCORD_GUILD_ID` environment variable to the configuration files, allowing for better integration with Discord for role synchronization. The event announcement functionality has been updated to include an option for the `@everyone` mention, which can be toggled during event creation. The backend logic has been modified to handle this new option, and corresponding updates have been made to the frontend to allow users to control the mention behavior. Additionally, tests have been added to ensure the correct functionality of these features.
This commit is contained in:
2026-07-19 11:34:11 +03:00
parent ae19c03542
commit c3624376b0
29 changed files with 1524 additions and 37 deletions

View File

@@ -21,6 +21,7 @@ type Store interface {
DeleteSession(context.Context, string) error
UpdatePlayer(context.Context, domain.Player) (domain.Player, error)
ListPlayers(context.Context) ([]domain.Player, error)
EnqueueDiscordRoleSync(context.Context, string, string, int64) error
CreateParticipant(context.Context, domain.Player, domain.RSVP) (domain.Player, domain.RSVP, error)
CreateEvent(context.Context, domain.Event) (domain.Event, error)
GetEvent(context.Context, string) (domain.Event, error)
@@ -59,7 +60,15 @@ type Store interface {
type Publisher interface{ Publish(topic string, value any) }
type EventAnnouncer interface {
AnnounceEventCreated(context.Context, domain.Event) error
AnnounceEventCreated(context.Context, domain.Event, bool) error
}
type CreateEventOptions struct {
PingEveryone bool
}
func (s *Service) enqueueDiscordRoleSync(ctx context.Context, eventID, action string) {
_ = s.Store.EnqueueDiscordRoleSync(ctx, eventID, action, s.Now().UnixNano())
}
type Service struct {
@@ -159,7 +168,7 @@ func (s *Service) UpdateOwnProfile(ctx context.Context, actor domain.Account, cu
return out, err
}
func (s *Service) CreateEvent(ctx context.Context, actor domain.Account, event domain.Event) (domain.Event, error) {
func (s *Service) CreateEvent(ctx context.Context, actor domain.Account, event domain.Event, options CreateEventOptions) (domain.Event, error) {
if !actor.IsStaff() {
return domain.Event{}, domain.ErrForbidden
}
@@ -177,7 +186,7 @@ func (s *Service) CreateEvent(ctx context.Context, actor domain.Account, event d
s.Bus.Publish("events", out)
if s.EventAnnouncer != nil {
announcementCtx, cancel := context.WithTimeout(ctx, s.AnnouncementTimeout)
_ = s.EventAnnouncer.AnnounceEventCreated(announcementCtx, out)
_ = s.EventAnnouncer.AnnounceEventCreated(announcementCtx, out, options.PingEveryone)
cancel()
}
}
@@ -381,6 +390,7 @@ func (s *Service) RenameTeam(ctx context.Context, actor domain.Account, player d
_ = s.Store.AppendAudit(ctx, actor.ID, "team.renamed", teamID, map[string]string{"name": name})
s.Bus.Publish("team:"+teamID, team)
s.Bus.Publish("event:"+team.EventID, team)
s.enqueueDiscordRoleSync(ctx, team.EventID, DiscordRoleActionReconcile)
}
return team, err
}