Friendlier messages

This commit is contained in:
Zaprit 2025-08-13 21:34:07 +01:00
commit 96d92c911c
3 changed files with 13 additions and 6 deletions

View file

@ -22,6 +22,6 @@
<value>Caution: Your username MUST match your PSN/RPCN username in order to be able to sign in from in-game.</value>
</data>
<data name="email_verify_notice" xml:space="preserve">
<value>The game will be read-only until you verify your email</value>
<value>You do not have an email set on your account or you have not verified it. You can set an email by opening the text chat and typing "/setemail [youremail@example.com]" (do not include the brackets), then check your inbox for a verification email.</value>
</data>
</root>

View file

@ -3,6 +3,7 @@ namespace LBPUnion.ProjectLighthouse.Localization.StringLists;
public static class RegisterStrings
{
public static readonly TranslatableString UsernameNotice = create("username_notice");
public static readonly TranslatableString EmailVerificationNotice = create("email_verify_notice");
private static TranslatableString create(string key) => new(TranslationAreas.Register, key);
}

View file

@ -3,7 +3,6 @@ using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization;
using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization;
@ -56,16 +55,23 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
{
GameTokenEntity token = this.GetToken();
string username = await this.database.UsernameFromGameToken(token);
UserEntity? user = await this.database.UserFromGameToken(token);
if (user == null) return this.Forbid();
StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText);
announceText.Replace("%user", username);
announceText.Replace("%user", user.Username);
announceText.Replace("%id", token.UserId.ToString());
if (ServerConfiguration.Instance.Mail.RequireEmailVerification)
{
announceText.Insert(0,
RegisterStrings.EmailVerificationNotice.Translate(user.Language) + "\n\n");
}
if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode)
{
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(user.Language) + "\n\n");
}
#if DEBUG
@ -102,7 +108,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
{
GameNotification verifyEmailNotification = new();
verifyEmailNotification.Type = NotificationType.ModerationNotification;
verifyEmailNotification.Text = LocalizationManager.GetLocalizedString(TranslationAreas.Register, user.Language, "email_verify_notice");
verifyEmailNotification.Text = RegisterStrings.EmailVerificationNotice.Translate(user.Language);
builder.AppendLine(LighthouseSerializer.Serialize(this.HttpContext.RequestServices, verifyEmailNotification));
}