This commit introduces functionality for managing event-specific RSVP roles in Discord, including roles for "Registered", "Going", "Maybe", and "Not Going". The `RoleWorker` has been enhanced to handle these roles based on user registrations, with localization support for role names in Russian and English. Additionally, the database schema has been updated to accommodate new role types and actions, and the service layer has been modified to trigger role synchronization upon relevant event updates. Tests have been added to ensure the correct behavior of the new RSVP handling logic.
73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
package application
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"mixmaker/backend/internal/domain"
|
|
)
|
|
|
|
const (
|
|
DiscordRoleScopeGlobal = "global"
|
|
DiscordRoleScopeEvent = "event"
|
|
|
|
DiscordRoleKindTank = "tank"
|
|
DiscordRoleKindDamage = "damage"
|
|
DiscordRoleKindSupport = "support"
|
|
DiscordRoleKindTeam = "team"
|
|
DiscordRoleKindCaptain = "captain"
|
|
DiscordRoleKindRegistered = "registered"
|
|
DiscordRoleKindGoing = "going"
|
|
DiscordRoleKindMaybe = "maybe"
|
|
DiscordRoleKindNotGoing = "not_going"
|
|
|
|
DiscordRoleActionReconcile = "reconcile"
|
|
DiscordRoleActionRSVP = "rsvp"
|
|
DiscordRoleActionTeardown = "teardown"
|
|
)
|
|
|
|
type DiscordManagedRole struct {
|
|
Scope string
|
|
EventID string
|
|
TeamID string
|
|
Kind string
|
|
DiscordRoleID string
|
|
RoleName string
|
|
}
|
|
|
|
type DiscordRoleSyncJob struct {
|
|
ID int64
|
|
EventID string
|
|
Action string
|
|
Generation int64
|
|
RoleSnapshot []string
|
|
Attempts int
|
|
}
|
|
|
|
type DiscordRoleRoster struct {
|
|
Roster domain.RosterDraft
|
|
PlayerDiscordIDs map[string]string
|
|
}
|
|
|
|
type DiscordRoleRegistration struct {
|
|
Event domain.Event
|
|
Registrations []domain.RSVP
|
|
PlayerDiscordIDs map[string]string
|
|
}
|
|
|
|
type DiscordRoleStore interface {
|
|
SeedDiscordRoleSyncJobs(context.Context) error
|
|
ClaimDiscordRoleSyncJob(context.Context) (DiscordRoleSyncJob, error)
|
|
CompleteDiscordRoleSyncJob(context.Context, int64, string) error
|
|
RetryDiscordRoleSyncJob(context.Context, int64, string, time.Time) error
|
|
ListDiscordManagedRoles(context.Context, string) ([]DiscordManagedRole, error)
|
|
UpsertDiscordManagedRole(context.Context, DiscordManagedRole) error
|
|
DeleteDiscordManagedRole(context.Context, DiscordManagedRole) error
|
|
ListDiscordRoleAssignments(context.Context, string) ([]string, error)
|
|
UpsertDiscordRoleAssignment(context.Context, string, string) error
|
|
DeleteDiscordRoleAssignment(context.Context, string, string) error
|
|
GetDiscordRoleRoster(context.Context, string) (DiscordRoleRoster, error)
|
|
ListActiveDiscordRoleRosters(context.Context) ([]DiscordRoleRoster, error)
|
|
GetDiscordRoleRegistration(context.Context, string) (DiscordRoleRegistration, error)
|
|
}
|