From a29d1fdb78789efc060148891cbada96a999711c Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 11 Dec 2024 01:44:00 +0100 Subject: [PATCH] feat: plain text emails --- Foxnouns.Backend/Foxnouns.Backend.csproj | 1 + .../Mailables/AccountCreationMailable.cs | 14 ++++++- .../Mailables/AddEmailMailable.cs | 14 ++++++- Foxnouns.Backend/packages.lock.json | 42 ++++++++----------- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/Foxnouns.Backend/Foxnouns.Backend.csproj b/Foxnouns.Backend/Foxnouns.Backend.csproj index c6f9605..4ed5c44 100644 --- a/Foxnouns.Backend/Foxnouns.Backend.csproj +++ b/Foxnouns.Backend/Foxnouns.Backend.csproj @@ -22,6 +22,7 @@ all + diff --git a/Foxnouns.Backend/Mailables/AccountCreationMailable.cs b/Foxnouns.Backend/Mailables/AccountCreationMailable.cs index ee86b48..9c33213 100644 --- a/Foxnouns.Backend/Mailables/AccountCreationMailable.cs +++ b/Foxnouns.Backend/Mailables/AccountCreationMailable.cs @@ -19,9 +19,21 @@ namespace Foxnouns.Backend.Mailables; public class AccountCreationMailable(Config config, AccountCreationMailableView view) : Mailable { + private string PlainText() => + $""" + Please continue creating a new pronouns.cc account by using the following link: + {view.BaseUrl}/auth/callback/email/{view.Code} + Note that this link will expire in one hour. + + If you didn't mean to create a new account, feel free to ignore this email. + """; + public override void Build() { - To(view.To).From(config.EmailAuth.From!).View("~/Views/Mail/AccountCreation.cshtml", view); + To(view.To) + .From(config.EmailAuth.From!) + .View("~/Views/Mail/AccountCreation.cshtml", view) + .Text(PlainText()); } } diff --git a/Foxnouns.Backend/Mailables/AddEmailMailable.cs b/Foxnouns.Backend/Mailables/AddEmailMailable.cs index f40ffc0..1d29d0f 100644 --- a/Foxnouns.Backend/Mailables/AddEmailMailable.cs +++ b/Foxnouns.Backend/Mailables/AddEmailMailable.cs @@ -19,9 +19,21 @@ namespace Foxnouns.Backend.Mailables; public class AddEmailMailable(Config config, AddEmailMailableView view) : Mailable { + private string PlainText() => + $""" + Hello @{view.Username}, please confirm adding this email address to your account by using the following link: + {view.BaseUrl}/auth/callback/email/{view.Code} + Note that this link will expire in one hour. + + If you didn't mean to link this email address to @{view.Username}, feel free to ignore this email. + """; + public override void Build() { - To(view.To).From(config.EmailAuth.From!).View("~/Views/Mail/AddEmail.cshtml", view); + To(view.To) + .From(config.EmailAuth.From!) + .View("~/Views/Mail/AddEmail.cshtml", view) + .Text(PlainText()); } } diff --git a/Foxnouns.Backend/packages.lock.json b/Foxnouns.Backend/packages.lock.json index 03170c1..801e650 100644 --- a/Foxnouns.Backend/packages.lock.json +++ b/Foxnouns.Backend/packages.lock.json @@ -124,6 +124,17 @@ "Microsoft.Extensions.Primitives": "9.0.0" } }, + "MimeKit": { + "type": "Direct", + "requested": "[4.9.0, )", + "resolved": "4.9.0", + "contentHash": "DZXXMZzmAABDxFhOSMb6SE8KKxcRd/sk1E6aJTUE5ys2FWOQhznYV2Gl3klaaSfqKn27hQ32haqquH1J8Z6kJw==", + "dependencies": { + "BouncyCastle.Cryptography": "2.5.0", + "System.Formats.Asn1": "8.0.1", + "System.Security.Cryptography.Pkcs": "8.0.1" + } + }, "Minio": { "type": "Direct", "requested": "[6.0.3, )", @@ -284,8 +295,8 @@ }, "BouncyCastle.Cryptography": { "type": "Transitive", - "resolved": "2.2.1", - "contentHash": "A6Zr52zVqJKt18ZBsTnX0qhG0kwIQftVAjLmszmkiR/trSp8H+xj1gUOzk7XHwaKgyREMSV1v9XaKrBUeIOdvQ==" + "resolved": "2.5.0", + "contentHash": "rc7vRCq/KD3GtIwSgRtjanGaBwTb9nLenFDZnEcauWlssuuEoxcbMfWA3QWWho6QDMSOSkWjs657McdHzEtEcw==" }, "CommunityToolkit.HighPerformance": { "type": "Transitive", @@ -633,17 +644,6 @@ "resolved": "1.6.17", "contentHash": "Le+kehlmrlQfuDFUt1zZ2dVwrhFQtKREdKBo+rexOwaCoYP0/qpgT9tLxCsZjsgR5Itk1UKPcbgO+FyaNid/bA==" }, - "MimeKit": { - "type": "Transitive", - "resolved": "4.3.0", - "contentHash": "39KDXuERDy5VmHIn7NnCWvIVp/Ar4qnxZWg9m06DfRqDbW1B6zFv9o3Tdoa4CCu71tE/0SRqRCN5Z+bbffw6uw==", - "dependencies": { - "BouncyCastle.Cryptography": "2.2.1", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Security.Cryptography.Pkcs": "7.0.3", - "System.Text.Encoding.CodePages": "7.0.0" - } - }, "Mono.TextTemplating": { "type": "Transitive", "resolved": "3.0.0", @@ -808,8 +808,8 @@ }, "System.Formats.Asn1": { "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "+nfpV0afLmvJW8+pLlHxRjz3oZJw4fkyU9MMEaMhCsHi/SN9bGF9q79ROubDiwTiCHezmK0uCWkPP7tGFP/4yg==" + "resolved": "8.0.1", + "contentHash": "XqKba7Mm/koKSjKMfW82olQdmfbI5yqeoLV/tidRp7fbh5rmHAQ5raDI/7SU0swTzv+jgqtUGkzmFxuUg0it1A==" }, "System.IO.Hashing": { "type": "Transitive", @@ -850,16 +850,8 @@ }, "System.Security.Cryptography.Pkcs": { "type": "Transitive", - "resolved": "7.0.3", - "contentHash": "yhwEHH5Gzl/VoADrXtt5XC95OFoSjNSWLHNutE7GwdOgefZVRvEXRSooSpL8HHm3qmdd9epqzsWg28UJemt22w==", - "dependencies": { - "System.Formats.Asn1": "7.0.0" - } - }, - "System.Text.Encoding.CodePages": { - "type": "Transitive", - "resolved": "7.0.0", - "contentHash": "LSyCblMpvOe0N3E+8e0skHcrIhgV2huaNcjUUEa8hRtgEAm36aGkRoC8Jxlb6Ra6GSfF29ftduPNywin8XolzQ==" + "resolved": "8.0.1", + "contentHash": "CoCRHFym33aUSf/NtWSVSZa99dkd0Hm7OCZUxORBjRB16LNhIEOf8THPqzIYlvKM0nNDAPTRBa1FxEECrgaxxA==" }, "System.Threading.Channels": { "type": "Transitive",