Skip to content

Conversation

@Arshadul-Monir
Copy link
Collaborator

@Arshadul-Monir Arshadul-Monir commented Feb 10, 2026

719

Description of changes

Added an admin-only POST route that takes a clubId and sends a test message to the Discord guild associated with a club, given its clubId, in the channel associated with the channelId stored for them

Checklist before review

  • I have done a thorough self-review of the PR
  • Copilot has reviewed my latest changes, and all comments have been fixed and/or closed.
  • If I have made database changes, I have made sure I followed all the db repo rules listed in the wiki here. (check if no db changes)
  • All tests have passed
  • I have successfully deployed this PR to staging
  • I have done manual QA in both dev (and staging if possible) and attached screenshots below.

Screenshots

Dev

image

Message auto-deleted after 10 secodnds:
image

Staging

@github-actions
Copy link
Contributor

Available PR Commands

  • /ai - Triggers all AI review commands at once
  • /review - AI review of the PR changes
  • /describe - AI-powered description of the PR
  • /improve - AI-powered suggestions
  • /deploy - Deploy to staging

See: https://github.com/tahminator/codebloom/wiki/CI-Commands

@github-actions
Copy link
Contributor

Title

719: Added route to send test discord message to club


PR Type

Enhancement


Description

  • Add admin POST /admin/discord/message/test endpoint

  • Send test embed to club leaderboard channel

  • Validate admin session and return status

  • Implement manager method to construct embed


Diagram Walkthrough

flowchart LR
  A["AdminController POST /admin/discord/message/test"] --> B["DiscordClubManager.sendTestEmbedMessageToClub"]
  B --> C["JDA Client connect/send"]
  C --> D["Discord Guild Leaderboard Channel"]
Loading

File Walkthrough

Relevant files
Enhancement
AdminController.java
Introduce admin Discord test message endpoint                       

src/main/java/org/patinanetwork/codebloom/api/admin/AdminController.java

  • Add POST /admin/discord/message/test endpoint
  • Validate admin via protector.validateAdminSession
  • Delegate to discordClubManager.sendTestEmbedMessageToClub
  • Return success or 500 with ApiResponder
+24/-0   
DiscordClubManager.java
Add method to send Discord test embed                                       

src/main/java/org/patinanetwork/codebloom/common/components/DiscordClubManager.java

  • Implement sendTestEmbedMessageToClub(String clubId)
  • Connect JDA, fetch club and metadata IDs
  • Build and send embed via EmbeddedImagesMessageOptions
  • Handle exceptions and return boolean status
+37/-0   

@github-actions
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

AC Not Met

The test message is never deleted after 10 seconds and no message ID is stored in memory, both of which are required by the acceptance criteria. Capture the sent message ID, schedule deletion after 10 seconds, and keep temporary in-memory storage for these IDs.

    jdaClient.sendEmbedWithImages(EmbeddedImagesMessageOptions.builder()
            .guildId(Long.valueOf(guildId.get()))
            .channelId(Long.valueOf(channelId.get()))
            .description(description)
            .title("Message for %s"
                    .formatted(club.getName()))
            .footerText("Codebloom - LeetCode Leaderboard for %s".formatted(club.getName()))
            .footerIcon("%s/favicon.ico".formatted(serverUrlUtils.getUrl()))
            .color(new Color(69, 129, 103))
            .build());
    return true;
} catch (Exception e){
Possible Issue

Optional values for guildId and channelId are dereferenced without presence checks, which can throw at runtime. Validate presence and return a meaningful error if either is missing.

var guildId = club.getDiscordClubMetadata().flatMap(DiscordClubMetadata::getGuildId);
var channelId = club.getDiscordClubMetadata().flatMap(DiscordClubMetadata::getLeaderboardChannelId);

jdaClient.sendEmbedWithImages(EmbeddedImagesMessageOptions.builder()
        .guildId(Long.valueOf(guildId.get()))
        .channelId(Long.valueOf(channelId.get()))
        .description(description)
API Contract Mismatch

The endpoint consumes a raw string instead of a JSON DTO with clubId and returns 500 for all failures while the Swagger docs declare 404. Validate input, return 400 for bad input and 404 when the club is not found, and align annotations with actual responses.

@PostMapping("/discord/message/test")
public ResponseEntity<ApiResponder<Empty>> sendDiscordMessage(@RequestBody final String clubId, final HttpServletRequest request) {
    protector.validateAdminSession(request);
    boolean sentMessage = discordClubManager.sendTestEmbedMessageToClub(clubId);

    if (!sentMessage) {
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body(ApiResponder.failure("Hmm, something went wrong."));
    }
    return ResponseEntity.ok(ApiResponder.success("Message successfully sent!", Empty.of()));
}

@Arshadul-Monir Arshadul-Monir force-pushed the 719 branch 4 times, most recently from 9532462 to ba9ef51 Compare February 10, 2026 18:48
@Arshadul-Monir
Copy link
Collaborator Author

/deploy

@Arshadul-Monir Arshadul-Monir force-pushed the 719 branch 4 times, most recently from 4d13e0f to eeea043 Compare February 11, 2026 17:36
@Arshadul-Monir
Copy link
Collaborator Author

/deploy

719: Admin message deletes self after 10 seconds
719: Added tests for sendDiscordMessage

719: Updated mockio test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant