mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-17 23:22:27 +00:00
Add webhook message when a new Team Pick is added (#528)
* Add webhook message when a new Team Pick is added * Update ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs Co-authored-by: Josh <josh@slendy.pw> * Update ModerationSlotController.cs * Include ServerConfiguration class Co-authored-by: Alex_Sour <52638772+Alex-Sour@users.noreply.github.com> Co-authored-by: Josh <josh@slendy.pw>
This commit is contained in:
parent
58a5311a7d
commit
84e2914e40
1 changed files with 7 additions and 2 deletions
|
@ -1,8 +1,10 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
using LBPUnion.ProjectLighthouse.Levels;
|
using LBPUnion.ProjectLighthouse.Levels;
|
||||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
||||||
|
|
||||||
|
@ -23,10 +25,13 @@ public class ModerationSlotController : ControllerBase
|
||||||
User? user = this.database.UserFromWebRequest(this.Request);
|
User? user = this.database.UserFromWebRequest(this.Request);
|
||||||
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
|
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();
|
if (slot == null) return this.NotFound();
|
||||||
slot.TeamPick = true;
|
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();
|
await this.database.SaveChangesAsync();
|
||||||
return this.Redirect("~/slot/" + id);
|
return this.Redirect("~/slot/" + id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue