mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-24 14:11:29 +00:00
Add a discord webhook for when users join for the first time. (#698)
* Add a discord webhook for when users join for the first time. * Fix compilation error related to embed colors * Make config migration backup use the version of the stored file * Make DiscordConfiguration not halt startup * Allow the registration message to be configured * Clean up registration announcement and add userId variable * Fix userid resolution and convert newline string to actual character Also make WebhookHelper not fail if all destinations aren't configured
This commit is contained in:
parent
b87c16ab7c
commit
fa5ff0b490
7 changed files with 90 additions and 26 deletions
|
@ -138,7 +138,20 @@ public class LoginController : ControllerBase
|
|||
user.LinkedRpcnId = npTicket.Platform == Platform.RPCS3 ? npTicket.UserId : 0;
|
||||
user.LinkedPsnId = npTicket.Platform != Platform.RPCS3 ? npTicket.UserId : 0;
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
|
||||
if (DiscordConfiguration.Instance.DiscordIntegrationEnabled)
|
||||
{
|
||||
string registrationAnnouncementMsg = DiscordConfiguration.Instance.RegistrationAnnouncement
|
||||
.Replace("%user", username)
|
||||
.Replace("%id", user.UserId.ToString())
|
||||
.Replace("%instance", ServerConfiguration.Instance.Customization.ServerName)
|
||||
.Replace("%platform", npTicket.Platform.ToString())
|
||||
.Replace(@"\n", "\n");
|
||||
await WebhookHelper.SendWebhook(title: "A new user has registered!",
|
||||
description: registrationAnnouncementMsg,
|
||||
dest: WebhookHelper.WebhookDestination.Registration);
|
||||
}
|
||||
|
||||
Logger.Success($"Created new user for {username}, platform={npTicket.Platform}", LogArea.Login);
|
||||
}
|
||||
// automatically change username if it doesn't match
|
||||
|
|
|
@ -139,7 +139,7 @@ public class PhotosController : ControllerBase
|
|||
Title = "New photo uploaded!",
|
||||
Description = $"{user.Username} uploaded a new photo.",
|
||||
ImageUrl = $"{ServerConfiguration.Instance.ExternalUrl}/gameAssets/{photo.LargeHash}",
|
||||
Color = WebhookHelper.UnionColor,
|
||||
Color = WebhookHelper.GetEmbedColor(),
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue