mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
General cleanup, move warning messages, fix bugs
This commit is contained in:
parent
cb6d77203b
commit
5bdb1c0501
5 changed files with 31 additions and 21 deletions
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="SqlDialectMappings">
|
|
||||||
<file url="PROJECT" dialect="MySQL" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -26,5 +26,10 @@ public static class BaseLayoutStrings
|
||||||
public static readonly TranslatableString ReadOnlyWarnTitle = create("read_only_warn_title");
|
public static readonly TranslatableString ReadOnlyWarnTitle = create("read_only_warn_title");
|
||||||
public static readonly TranslatableString ReadOnlyWarn = create("read_only_warn");
|
public static readonly TranslatableString ReadOnlyWarn = create("read_only_warn");
|
||||||
|
|
||||||
|
public static readonly TranslatableString EmailEnforcementWarnMain = create("email_enforcement_message_main");
|
||||||
|
public static readonly TranslatableString EmailEnforcementWarnNoEmail = create("email_enforcement_message_no_email");
|
||||||
|
public static readonly TranslatableString EmailEnforcementWarnVerifyEmail = create("email_enforcement_message_verify_email");
|
||||||
|
|
||||||
|
|
||||||
private static TranslatableString create(string key) => new(TranslationAreas.BaseLayout, key);
|
private static TranslatableString create(string key) => new(TranslationAreas.BaseLayout, key);
|
||||||
}
|
}
|
|
@ -60,32 +60,26 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
||||||
StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText);
|
StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText);
|
||||||
|
|
||||||
announceText.Replace("%user", user.Username);
|
announceText.Replace("%user", user.Username);
|
||||||
announceText.Replace("%id", user.UserId.ToString());
|
announceText.Replace("%id", token.UserId.ToString());
|
||||||
|
|
||||||
if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode)
|
if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode)
|
||||||
{
|
{
|
||||||
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
|
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EnforceEmailConfiguration.Instance.EnableEmailEnforcement && user.EmailAddress == null)
|
if (EnforceEmailConfiguration.Instance.EnableEmailEnforcement)
|
||||||
{
|
{
|
||||||
|
announceText.Insert(0, EnforceEmailConfiguration.Instance.EmailEnforcementMessageMain);
|
||||||
|
|
||||||
if (user.EmailAddress == null)
|
if (user.EmailAddress == null)
|
||||||
{
|
{
|
||||||
// This will probably need translations
|
// This will probably need translations
|
||||||
announceText.Insert(0,
|
announceText.Insert(0, EnforceEmailConfiguration.Instance.EmailEnforcementMessageNoEmail);
|
||||||
"This server instance has email enforcement enabled, " +
|
|
||||||
"you will need to set and verify an email address to use most features.\n" +
|
|
||||||
"You can set an email by opening the text chat and typing " +
|
|
||||||
"\"/setemail [youremail@example.com]\" (do not include the brackets.\n\n");
|
|
||||||
}
|
}
|
||||||
if (!user.EmailAddressVerified)
|
else if (!user.EmailAddressVerified)
|
||||||
{
|
{
|
||||||
// More stuff to translate later
|
// More stuff to translate later
|
||||||
announceText.Insert(0,
|
announceText.Insert(0, EnforceEmailConfiguration.Instance.EmailEnforcementMessageVerify);
|
||||||
"You have set an email address on your account, but you have not verified " +
|
|
||||||
"it. Make sure to check your inbox for a verification email. " +
|
|
||||||
"If you have not received an email, please contact an instance " +
|
|
||||||
"administrator for further assistance.\n\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,23 @@ public class EnforceEmailConfiguration : ConfigurationBase<EnforceEmailConfigura
|
||||||
|
|
||||||
// No blacklist by default, add path to blacklist
|
// No blacklist by default, add path to blacklist
|
||||||
public string BlacklistFilePath { get; set; } = "";
|
public string BlacklistFilePath { get; set; } = "";
|
||||||
|
|
||||||
|
// Keep warnings here for debug until pull
|
||||||
|
public string EmailEnforcementMessageMain { get; set; } =
|
||||||
|
"This lighthouse instance has email enforcement enabled. " +
|
||||||
|
"If you haven't already, you will need to set and verify " +
|
||||||
|
"an email address to use most features.\n";
|
||||||
|
|
||||||
|
public string EmailEnforcementMessageNoEmail { get; set; } =
|
||||||
|
"You do not have an email set on your account. You can set " +
|
||||||
|
"an email by opening the text chat and typing \"<em>/setemail " +
|
||||||
|
"[youremail@example.com]</em>\" (do not include the brackets.)\n\n";
|
||||||
|
|
||||||
|
public string EmailEnforcementMessageVerify { get; set; } =
|
||||||
|
"You have set an email address on your account, but you have not " +
|
||||||
|
"verified it. Make sure to check your inbox for a verification email. " +
|
||||||
|
"If you have not received an email, please contact an instance " +
|
||||||
|
"administrator for further assistance.\n\n";
|
||||||
|
|
||||||
public override ConfigurationBase<EnforceEmailConfiguration> Deserialize
|
public override ConfigurationBase<EnforceEmailConfiguration> Deserialize
|
||||||
(IDeserializer deserializer, string text) =>
|
(IDeserializer deserializer, string text) =>
|
||||||
|
|
|
@ -90,8 +90,8 @@ public static class SMTPHelper
|
||||||
// Get domain by splitting at '@' character
|
// Get domain by splitting at '@' character
|
||||||
string domain = email.Split('@')[1];
|
string domain = email.Split('@')[1];
|
||||||
|
|
||||||
// Return true if domain is found in blacklist
|
// Return false if domain is found in blacklist
|
||||||
return blacklistedDomains.Contains(domain);
|
return !blacklistedDomains.Contains(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue