5 Commits

Author SHA1 Message Date
377e19ca78 Merge branch 'main' into dependabot/bundler/docs/commonmarker-0.23.10 2024-06-07 00:53:50 +00:00
259cc91a11 Merge pull request 'Bump activesupport from 7.0.4.3 to 7.0.7.2 in /docs' (#49) from dependabot/bundler/docs/activesupport-7.0.7.2 into main
Reviewed-on: #49
2024-06-07 00:53:20 +00:00
dependabot[bot]
cd41aef0ba Bump activesupport from 7.0.4.3 to 7.0.7.2 in /docs
Bumps [activesupport](https://github.com/rails/rails) from 7.0.4.3 to 7.0.7.2.
- [Release notes](https://github.com/rails/rails/releases)
- [Changelog](https://github.com/rails/rails/blob/v7.0.7.2/activesupport/CHANGELOG.md)
- [Commits](https://github.com/rails/rails/compare/v7.0.4.3...v7.0.7.2)

---
updated-dependencies:
- dependency-name: activesupport
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-23 21:43:25 +00:00
dependabot[bot]
8aa3e41f50 Bump commonmarker from 0.23.9 to 0.23.10 in /docs
Bumps [commonmarker](https://github.com/gjtorikian/commonmarker) from 0.23.9 to 0.23.10.
- [Release notes](https://github.com/gjtorikian/commonmarker/releases)
- [Changelog](https://github.com/gjtorikian/commonmarker/blob/v0.23.10/CHANGELOG.md)
- [Commits](https://github.com/gjtorikian/commonmarker/compare/v0.23.9...v0.23.10)

---
updated-dependencies:
- dependency-name: commonmarker
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-08 20:26:42 +00:00
39af0fb9a5 Implement e-mail changes
- Add canonical domain handling
- Bump version
2023-07-12 20:46:01 -04:00
8 changed files with 47 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (7.0.4.3) activesupport (7.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
minitest (>= 5.1) minitest (>= 5.1)
@@ -13,7 +13,7 @@ GEM
execjs execjs
coffee-script-source (1.11.1) coffee-script-source (1.11.1)
colorator (1.1.0) colorator (1.1.0)
commonmarker (0.23.9) commonmarker (0.23.10)
concurrent-ruby (1.2.2) concurrent-ruby (1.2.2)
dnsruby (1.70.0) dnsruby (1.70.0)
simpleidn (~> 0.2.1) simpleidn (~> 0.2.1)
@@ -86,7 +86,7 @@ GEM
activesupport (>= 2) activesupport (>= 2)
nokogiri (>= 1.4) nokogiri (>= 1.4)
http_parser.rb (0.8.0) http_parser.rb (0.8.0)
i18n (1.13.0) i18n (1.14.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jekyll (3.9.3) jekyll (3.9.3)
addressable (~> 2.4) addressable (~> 2.4)
@@ -209,7 +209,7 @@ GEM
jekyll (>= 3.5, < 5.0) jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9) jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1) jekyll-seo-tag (~> 2.1)
minitest (5.18.0) minitest (5.19.0)
nokogiri (1.15.1-x86_64-linux) nokogiri (1.15.1-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
octokit (4.25.1) octokit (4.25.1)

View File

@@ -1,2 +1,3 @@
**/bin/* **/bin/*
**/obj/* **/obj/*
**/appsettings.*

View File

@@ -1,11 +1,11 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<AssemblyVersion>8.1.0.0</AssemblyVersion> <AssemblyVersion>8.2.0.0</AssemblyVersion>
<FileVersion>8.1.0.0</FileVersion> <FileVersion>8.2.0.0</FileVersion>
<Authors>danieljsummers</Authors> <Authors>danieljsummers</Authors>
<Company>Bit Badger Solutions</Company> <Company>Bit Badger Solutions</Company>
<Version>8.1.0</Version> <Version>8.2.0</Version>
<DebugType>Embedded</DebugType> <DebugType>Embedded</DebugType>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -70,6 +70,9 @@ module Configure =
let _ = dsb.UseNodaTime() let _ = dsb.UseNodaTime()
Configuration.useDataSource (dsb.Build ()) Configuration.useDataSource (dsb.Build ())
let emailCfg = cfg.GetSection "Email"
if (emailCfg.GetChildren >> Seq.isEmpty >> not) () then ConfigurationBinder.Bind(emailCfg, Email.smtpOptions)
let _ = svc.AddSingleton<IDistributedCache, DistributedCache> () let _ = svc.AddSingleton<IDistributedCache, DistributedCache> ()
let _ = svc.AddSession () let _ = svc.AddSession ()
let _ = svc.AddAntiforgery () let _ = svc.AddAntiforgery ()
@@ -182,6 +185,7 @@ module Configure =
|> function l -> l.AddConsole().AddDebug() |> function l -> l.AddConsole().AddDebug()
|> ignore |> ignore
open BitBadger.AspNetCore.CanonicalDomains
open Microsoft.Extensions.Localization open Microsoft.Extensions.Localization
open Microsoft.Extensions.Options open Microsoft.Extensions.Options
@@ -189,12 +193,13 @@ module Configure =
let app (app : IApplicationBuilder) = let app (app : IApplicationBuilder) =
let env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment> () let env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment> ()
if env.IsDevelopment () then if env.IsDevelopment () then
let _ = app.UseDeveloperExceptionPage () app.UseDeveloperExceptionPage ()
()
else else
let _ = app.UseGiraffeErrorHandler errorHandler app.UseGiraffeErrorHandler errorHandler
() |> ignore
let _ = app.UseForwardedHeaders ()
let _ = app.UseCanonicalDomains ()
let _ = app.UseStatusCodePagesWithReExecute "/error/{0}" let _ = app.UseStatusCodePagesWithReExecute "/error/{0}"
let _ = app.UseStaticFiles () let _ = app.UseStaticFiles ()
let _ = app.UseCookiePolicy (CookiePolicyOptions (MinimumSameSitePolicy = SameSiteMode.Strict)) let _ = app.UseCookiePolicy (CookiePolicyOptions (MinimumSameSitePolicy = SameSiteMode.Strict))

View File

@@ -30,23 +30,39 @@ type EmailOptions =
Strings : IStringLocalizer Strings : IStringLocalizer
} }
/// The e-mail address from which e-mail is sent /// Options to use when sending e-mail
let private fromAddress = "prayer@bitbadger.solutions" type SmtpServerOptions() =
/// The hostname of the SMTP server
member val SmtpHost : string = "localhost" with get, set
open MailKit.Security /// The port over which SMTP communication should occur
open Microsoft.Extensions.Configuration member val Port : int = 25 with get, set
/// Whether to use SSL when communicating with the SMTP server
member val UseSsl : bool = false with get, set
/// The authentication to use with the SMTP server
member val Authentication : string = "" with get, set
/// The e-mail address from which messages should be sent
member val FromAddress : string = "prayer@bitbadger.solutions" with get, set
/// The options for the SMTP server
let smtpOptions = SmtpServerOptions ()
/// Get an SMTP client connection /// Get an SMTP client connection
let getConnection (cfg : IConfiguration) = task { let getConnection () = task {
let client = new SmtpClient () let client = new SmtpClient ()
do! client.ConnectAsync (cfg.GetConnectionString "SmtpServer", 25, SecureSocketOptions.None) do! client.ConnectAsync (smtpOptions.SmtpHost, smtpOptions.Port, smtpOptions.UseSsl)
do! client.AuthenticateAsync (smtpOptions.FromAddress, smtpOptions.Authentication)
return client return client
} }
/// Create a mail message object, filled with everything but the body content /// Create a mail message object, filled with everything but the body content
let createMessage opts = let createMessage opts =
let msg = new MimeMessage () let msg = new MimeMessage ()
msg.From.Add (MailboxAddress (opts.Group.Preferences.EmailFromName, fromAddress)) msg.From.Add (MailboxAddress (opts.Group.Preferences.EmailFromName, smtpOptions.FromAddress))
msg.Subject <- opts.Subject msg.Subject <- opts.Subject
msg.ReplyTo.Add (MailboxAddress (opts.Group.Preferences.EmailFromName, opts.Group.Preferences.EmailFromAddress)) msg.ReplyTo.Add (MailboxAddress (opts.Group.Preferences.EmailFromName, opts.Group.Preferences.EmailFromAddress))
msg msg

View File

@@ -88,7 +88,7 @@ let email date : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
let! list = generateRequestList ctx listDate let! list = generateRequestList ctx listDate
let group = ctx.Session.CurrentGroup.Value let group = ctx.Session.CurrentGroup.Value
let! recipients = Members.forGroup group.Id let! recipients = Members.forGroup group.Id
use! client = Email.getConnection (ctx.GetService<IConfiguration> ()) use! client = Email.getConnection ()
do! Email.sendEmails do! Email.sendEmails
{ Client = client { Client = client
Recipients = recipients Recipients = recipients
@@ -98,6 +98,7 @@ let email date : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
PlainTextBody = list.AsText s PlainTextBody = list.AsText s
Strings = s Strings = s
} }
do! client.DisconnectAsync true
return! return!
viewInfo ctx viewInfo ctx
|> Views.PrayerRequest.email { list with Recipients = recipients } |> Views.PrayerRequest.email { list with Recipients = recipients }

View File

@@ -24,6 +24,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BitBadger.AspNetCore.CanonicalDomains" Version="1.0.0" />
<PackageReference Include="Giraffe.Htmx" Version="1.9.2" /> <PackageReference Include="Giraffe.Htmx" Version="1.9.2" />
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.1" /> <PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.1" />
<PackageReference Update="FSharp.Core" Version="7.0.300" /> <PackageReference Update="FSharp.Core" Version="7.0.300" />

View File

@@ -269,7 +269,7 @@ let sendAnnouncement : HttpHandler = requireAccess [ User ] >=> validateCsrf >=>
return users |> List.map (fun u -> { Member.empty with Name = u.Name; Email = u.Email }) return users |> List.map (fun u -> { Member.empty with Name = u.Name; Email = u.Email })
else return! Members.forGroup group.Id else return! Members.forGroup group.Id
} }
use! client = Email.getConnection (ctx.GetService<IConfiguration> ()) use! client = Email.getConnection ()
do! Email.sendEmails do! Email.sendEmails
{ Client = client { Client = client
Recipients = recipients Recipients = recipients
@@ -280,6 +280,7 @@ let sendAnnouncement : HttpHandler = requireAccess [ User ] >=> validateCsrf >=>
PlainTextBody = plainText PlainTextBody = plainText
Strings = s Strings = s
} }
do! client.DisconnectAsync true
// Add to the request list if desired // Add to the request list if desired
match model.SendToClass, model.AddToRequestList with match model.SendToClass, model.AddToRequestList with
| "N", _ | "N", _