feat: plain text emails

This commit is contained in:
sam 2024-12-11 01:44:00 +01:00
parent 7e6698c3fb
commit a29d1fdb78
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
4 changed files with 44 additions and 27 deletions

View file

@ -22,6 +22,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0"/>
<PackageReference Include="MimeKit" Version="4.9.0"/>
<PackageReference Include="Minio" Version="6.0.3"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="NodaTime" Version="3.2.0"/>

View file

@ -19,9 +19,21 @@ namespace Foxnouns.Backend.Mailables;
public class AccountCreationMailable(Config config, AccountCreationMailableView view)
: Mailable<AccountCreationMailableView>
{
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());
}
}

View file

@ -19,9 +19,21 @@ namespace Foxnouns.Backend.Mailables;
public class AddEmailMailable(Config config, AddEmailMailableView view)
: Mailable<AddEmailMailableView>
{
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());
}
}

View file

@ -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",