diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs index f7cf2ec6..20ebae4a 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs @@ -1,8 +1,10 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Levels; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using LBPUnion.ProjectLighthouse.Helpers; namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin; @@ -23,10 +25,13 @@ public class ModerationSlotController : ControllerBase User? user = this.database.UserFromWebRequest(this.Request); if (user == null || !user.IsModerator) return this.StatusCode(403, ""); - Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id); + Slot? slot = await this.database.Slots.Include(s => s.Creator).FirstOrDefaultAsync(s => s.SlotId == id); if (slot == null) return this.NotFound(); slot.TeamPick = true; + // Send webhook with slot.Name and slot.Creator.Username + await WebhookHelper.SendWebhook("New Team Pick!", $"The level [**{slot.Name}**]({ServerConfiguration.Instance.ExternalUrl}/slot/{slot.SlotId}) by **{slot.Creator?.Username}** has been team picked"); + await this.database.SaveChangesAsync(); return this.Redirect("~/slot/" + id); } @@ -58,4 +63,4 @@ public class ModerationSlotController : ControllerBase return this.Redirect("~/slots/0"); } -} \ No newline at end of file +}