using System.Diagnostics.CodeAnalysis; using InnovEnergy.App.Backend.DataTypes; using InnovEnergy.Lib.Mailer; using JsonSerializer = System.Text.Json.JsonSerializer; namespace InnovEnergy.App.Backend.Email; public static class Email { [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] public static Boolean SendVerificationMessage(User emailRecipientUser) { var config = JsonSerializer.Deserialize(File.OpenRead("./Resources/smtpConfig.json"))!; var mailer = new Mailer(); mailer.From("InnovEnergy", "noreply@innov.energy"); mailer.To(emailRecipientUser.Name, emailRecipientUser.Email); mailer.Subject("Create a new password for your Innovenergy-Account"); mailer.Body("Dear " + emailRecipientUser.Name + "\n Please create a new password for your Innovenergy-account." + "\n To do this just login at https://HEEEEELP"); return mailer.SendEmailUsingSmtpConfig(config); } [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] public static Boolean SendPasswordResetMessage (User emailRecipientUser, String token) { var config = JsonSerializer.Deserialize(File.OpenRead("./Resources/smtpConfig.json"))!; //todo am I right? const String resetLink = "https://monitor.innov.energy/api/ResetPassword"; var mailer = new Mailer(); try { mailer.From("InnovEnergy", "noreply@innov.energy"); mailer.To(emailRecipientUser.Name, emailRecipientUser.Email); mailer.Subject("Reset the password of your Innovenergy-Account"); mailer.Body("Dear " + emailRecipientUser.Name + "\n To reset your password open this link:" + resetLink + "?token=" + token); return mailer.SendEmailUsingSmtpConfig(config); } catch (Exception) { return false; } } }