Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fdb8f2ebf1 | |||
| 0f9837c257 | |||
| 51ad71074c | |||
| 377e19ca78 | |||
| 259cc91a11 | |||
| 131012b320 | |||
|
|
cd41aef0ba | ||
|
|
8aa3e41f50 | ||
| 39af0fb9a5 |
@@ -1,7 +1,7 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (7.0.4.3)
|
||||
activesupport (7.0.7.2)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
@@ -13,7 +13,7 @@ GEM
|
||||
execjs
|
||||
coffee-script-source (1.11.1)
|
||||
colorator (1.1.0)
|
||||
commonmarker (0.23.9)
|
||||
commonmarker (0.23.10)
|
||||
concurrent-ruby (1.2.2)
|
||||
dnsruby (1.70.0)
|
||||
simpleidn (~> 0.2.1)
|
||||
@@ -86,7 +86,7 @@ GEM
|
||||
activesupport (>= 2)
|
||||
nokogiri (>= 1.4)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.13.0)
|
||||
i18n (1.14.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jekyll (3.9.3)
|
||||
addressable (~> 2.4)
|
||||
@@ -209,7 +209,7 @@ GEM
|
||||
jekyll (>= 3.5, < 5.0)
|
||||
jekyll-feed (~> 0.9)
|
||||
jekyll-seo-tag (~> 2.1)
|
||||
minitest (5.18.0)
|
||||
minitest (5.19.0)
|
||||
nokogiri (1.15.1-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
octokit (4.25.1)
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
**/bin/*
|
||||
**/obj/*
|
||||
**/appsettings.*
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<AssemblyVersion>8.1.0.0</AssemblyVersion>
|
||||
<FileVersion>8.1.0.0</FileVersion>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyVersion>8.3.0.0</AssemblyVersion>
|
||||
<FileVersion>8.3.0.0</FileVersion>
|
||||
<Authors>danieljsummers</Authors>
|
||||
<Company>Bit Badger Solutions</Company>
|
||||
<Version>8.1.0</Version>
|
||||
<Version>8.3.0</Version>
|
||||
<DebugType>Embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||
WORKDIR /pt
|
||||
COPY ./PrayerTracker.sln ./
|
||||
COPY ./Directory.Build.props ./
|
||||
@@ -15,11 +15,11 @@ RUN dotnet run
|
||||
WORKDIR /pt/PrayerTracker
|
||||
RUN dotnet publish -c Release -r linux-x64
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine as final
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine as final
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache icu-libs
|
||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||
COPY --from=build /pt/PrayerTracker/bin/Release/net7.0/linux-x64/publish/ ./
|
||||
COPY --from=build /pt/PrayerTracker/bin/Release/net8.0/linux-x64/publish/ ./
|
||||
|
||||
EXPOSE 80
|
||||
CMD [ "dotnet", "/app/PrayerTracker.dll" ]
|
||||
|
||||
@@ -103,7 +103,7 @@ module private Helpers =
|
||||
}
|
||||
|
||||
|
||||
open BitBadger.Npgsql.FSharp.Documents
|
||||
open BitBadger.Documents.Postgres
|
||||
|
||||
/// Functions to manipulate churches
|
||||
module Churches =
|
||||
|
||||
@@ -47,7 +47,7 @@ module private CacheHelpers =
|
||||
p.ParameterName, Sql.parameter p
|
||||
|
||||
|
||||
open BitBadger.Npgsql.FSharp.Documents
|
||||
open BitBadger.Documents.Postgres
|
||||
|
||||
/// A distributed cache implementation in PostgreSQL used to handle sessions for myWebLog
|
||||
type DistributedCache () =
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BitBadger.Npgsql.FSharp.Documents" Version="1.0.0-beta3" />
|
||||
<PackageReference Include="Giraffe" Version="6.0.0" />
|
||||
<PackageReference Include="NodaTime" Version="3.1.9" />
|
||||
<PackageReference Include="BitBadger.Documents.Postgres" Version="3.1.0" />
|
||||
<PackageReference Include="Giraffe" Version="6.4.0" />
|
||||
<PackageReference Include="NodaTime" Version="3.1.11" />
|
||||
<PackageReference Include="Npgsql.FSharp" Version="5.7.0" />
|
||||
<PackageReference Include="Npgsql.NodaTime" Version="7.0.4" />
|
||||
<PackageReference Update="FSharp.Core" Version="7.0.300" />
|
||||
<PackageReference Include="Npgsql.NodaTime" Version="8.0.3" />
|
||||
<PackageReference Update="FSharp.Core" Version="8.0.300" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Expecto" Version="9.0.4" />
|
||||
<PackageReference Include="NodaTime.Testing" Version="3.1.9" />
|
||||
<PackageReference Update="FSharp.Core" Version="7.0.300" />
|
||||
<PackageReference Include="NodaTime.Testing" Version="3.1.11" />
|
||||
<PackageReference Update="FSharp.Core" Version="8.0.300" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Giraffe.ViewEngine" Version="1.4.0" />
|
||||
<PackageReference Include="Giraffe.ViewEngine.Htmx" Version="1.9.2" />
|
||||
<PackageReference Include="MailKit" Version="4.1.0" />
|
||||
<PackageReference Include="Giraffe.ViewEngine.Htmx" Version="1.9.12" />
|
||||
<PackageReference Include="MailKit" Version="4.6.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Update="FSharp.Core" Version="7.0.300" />
|
||||
<PackageReference Update="FSharp.Core" Version="8.0.300" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -35,7 +35,7 @@ module Configure =
|
||||
(ctx.Configuration.GetSection >> opts.Configure >> ignore) "Kestrel"
|
||||
|
||||
open System.Globalization
|
||||
open BitBadger.Npgsql.FSharp.Documents
|
||||
open BitBadger.Documents.Postgres
|
||||
open Microsoft.AspNetCore.Authentication.Cookies
|
||||
open Microsoft.AspNetCore.Localization
|
||||
open Microsoft.Extensions.Caching.Distributed
|
||||
@@ -70,6 +70,9 @@ module Configure =
|
||||
let _ = dsb.UseNodaTime()
|
||||
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.AddSession ()
|
||||
let _ = svc.AddAntiforgery ()
|
||||
@@ -182,6 +185,7 @@ module Configure =
|
||||
|> function l -> l.AddConsole().AddDebug()
|
||||
|> ignore
|
||||
|
||||
open BitBadger.AspNetCore.CanonicalDomains
|
||||
open Microsoft.Extensions.Localization
|
||||
open Microsoft.Extensions.Options
|
||||
|
||||
@@ -189,12 +193,13 @@ module Configure =
|
||||
let app (app : IApplicationBuilder) =
|
||||
let env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment> ()
|
||||
if env.IsDevelopment () then
|
||||
let _ = app.UseDeveloperExceptionPage ()
|
||||
()
|
||||
app.UseDeveloperExceptionPage ()
|
||||
else
|
||||
let _ = app.UseGiraffeErrorHandler errorHandler
|
||||
()
|
||||
app.UseGiraffeErrorHandler errorHandler
|
||||
|> ignore
|
||||
|
||||
let _ = app.UseForwardedHeaders ()
|
||||
let _ = app.UseCanonicalDomains ()
|
||||
let _ = app.UseStatusCodePagesWithReExecute "/error/{0}"
|
||||
let _ = app.UseStaticFiles ()
|
||||
let _ = app.UseCookiePolicy (CookiePolicyOptions (MinimumSameSitePolicy = SameSiteMode.Strict))
|
||||
|
||||
@@ -30,23 +30,39 @@ type EmailOptions =
|
||||
Strings : IStringLocalizer
|
||||
}
|
||||
|
||||
/// The e-mail address from which e-mail is sent
|
||||
let private fromAddress = "prayer@bitbadger.solutions"
|
||||
/// Options to use when sending e-mail
|
||||
type SmtpServerOptions() =
|
||||
/// The hostname of the SMTP server
|
||||
member val SmtpHost : string = "localhost" with get, set
|
||||
|
||||
open MailKit.Security
|
||||
open Microsoft.Extensions.Configuration
|
||||
/// The port over which SMTP communication should occur
|
||||
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
|
||||
let getConnection (cfg : IConfiguration) = task {
|
||||
let getConnection () = task {
|
||||
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
|
||||
}
|
||||
|
||||
/// Create a mail message object, filled with everything but the body content
|
||||
let createMessage opts =
|
||||
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.ReplyTo.Add (MailboxAddress (opts.Group.Preferences.EmailFromName, opts.Group.Preferences.EmailFromAddress))
|
||||
msg
|
||||
|
||||
@@ -88,7 +88,7 @@ let email date : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
|
||||
let! list = generateRequestList ctx listDate
|
||||
let group = ctx.Session.CurrentGroup.Value
|
||||
let! recipients = Members.forGroup group.Id
|
||||
use! client = Email.getConnection (ctx.GetService<IConfiguration> ())
|
||||
use! client = Email.getConnection ()
|
||||
do! Email.sendEmails
|
||||
{ Client = client
|
||||
Recipients = recipients
|
||||
@@ -98,6 +98,7 @@ let email date : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
|
||||
PlainTextBody = list.AsText s
|
||||
Strings = s
|
||||
}
|
||||
do! client.DisconnectAsync true
|
||||
return!
|
||||
viewInfo ctx
|
||||
|> Views.PrayerRequest.email { list with Recipients = recipients }
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Giraffe.Htmx" Version="1.9.2" />
|
||||
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.1" />
|
||||
<PackageReference Update="FSharp.Core" Version="7.0.300" />
|
||||
<PackageReference Include="BitBadger.AspNetCore.CanonicalDomains" Version="1.0.0" />
|
||||
<PackageReference Include="Giraffe.Htmx" Version="1.9.12" />
|
||||
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.1.0" />
|
||||
<PackageReference Update="FSharp.Core" Version="8.0.300" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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 })
|
||||
else return! Members.forGroup group.Id
|
||||
}
|
||||
use! client = Email.getConnection (ctx.GetService<IConfiguration> ())
|
||||
use! client = Email.getConnection ()
|
||||
do! Email.sendEmails
|
||||
{ Client = client
|
||||
Recipients = recipients
|
||||
@@ -280,6 +280,7 @@ let sendAnnouncement : HttpHandler = requireAccess [ User ] >=> validateCsrf >=>
|
||||
PlainTextBody = plainText
|
||||
Strings = s
|
||||
}
|
||||
do! client.DisconnectAsync true
|
||||
// Add to the request list if desired
|
||||
match model.SendToClass, model.AddToRequestList with
|
||||
| "N", _
|
||||
|
||||
Reference in New Issue
Block a user