Skip to content

bug(leaderboard): SlackWeeklyLeaderboardTask uses global config instead of workspace settings #751

@FelixTJDietrich

Description

@FelixTJDietrich

Bug Description

SlackWeeklyLeaderboardTask sends leaderboard notifications to a global Slack channel instead of using workspace-specific notification settings.

Current Behavior

File: leaderboard/tasks/SlackWeeklyLeaderboardTask.java:191-192

// CURRENT: Uses global properties for ALL workspaces
String team = leaderboardProperties.notification().team();
String channelId = leaderboardProperties.notification().channelId();

for (Workspace workspace : workspaces) {
    // ... builds leaderboard ...
    slackMessageService.sendMessage(channelId, blocks, "...");  // Same channel for everyone!
}

Expected Behavior

for (Workspace workspace : workspaces) {
    // Skip workspaces with notifications disabled
    if (!Boolean.TRUE.equals(workspace.getLeaderboardNotificationEnabled())) {
        continue;
    }
    
    // Use workspace-specific settings
    String team = workspace.getLeaderboardNotificationTeam();
    String channelId = workspace.getLeaderboardNotificationChannelId();
    
    if (channelId == null || channelId.isBlank()) {
        log.warn("Skipping workspace {}: no notification channel configured", workspace.getSlug());
        continue;
    }
    
    // ... build and send leaderboard ...
}

Impact

  • All workspaces send to the same global Slack channel
  • Workspace-specific leaderboardNotificationChannelId is never used
  • Workspace-specific leaderboardNotificationTeam is never used
  • Workspace-specific leaderboardNotificationEnabled is never checked
  • Multi-tenant Slack notifications are broken

Workspace Entity Fields (Exist But Unused)

// In Workspace.java - these fields exist but are ignored!
private Boolean leaderboardNotificationEnabled;
private String leaderboardNotificationTeam;
private String leaderboardNotificationChannelId;

Additional Issue: SlackAppConfig Singleton

SlackAppConfig.java creates a singleton Slack App using global env vars. For true multi-tenant support, we need per-workspace Slack clients using workspace.getSlackToken().

Fix Approach

  1. Quick fix: Update SlackWeeklyLeaderboardTask to use workspace fields
  2. Full fix: Also update SlackAppConfig to support per-workspace Slack tokens

Related Issues

Acceptance Criteria

  • Task checks workspace.getLeaderboardNotificationEnabled() before sending
  • Task uses workspace.getLeaderboardNotificationChannelId() per workspace
  • Task uses workspace.getLeaderboardNotificationTeam() per workspace
  • Workspaces without channel configured are skipped with warning log
  • Unit test verifies per-workspace channel usage

Metadata

Metadata

Assignees

No one assigned

    Labels

    application-serverSpring Boot server: APIs, business logic, databasebugSomething isn't workingpriority:criticalDrop everything - Loss of functionality or datapriority:highAddress this sprint - Significant impact

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions