Skip to content

Commit

Permalink
chore: dependency update fallout
Browse files Browse the repository at this point in the history
  • Loading branch information
blackfyre committed Jan 28, 2025
1 parent ae9276c commit b72af0f
Show file tree
Hide file tree
Showing 42 changed files with 800 additions and 1,176 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ guestbook.json
# this file is used for cache only
contributors.json

# Dependecies shouldn't be a part of the source code
# Dependencies shouldn't be a part of the source code
node_modules
meta.json

Expand Down
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,41 @@
"daisyui",
"daos",
"devenv",
"direnv",
"esbuild",
"flyctl",
"fontawesome",
"fsys",
"Galicz",
"goarch",
"godotenv",
"golangci",
"Goreleaser",
"gotest",
"govet",
"Htmx",
"isaack",
"joho",
"koedijck",
"labstack",
"Lexend",
"mailhog",
"Mailpit",
"metafile",
"migratecmd",
"Miklós",
"mjml",
"nixos",
"nixpkgs",
"onclick",
"outbase",
"outdir",
"pcss",
"pkgs",
"pocketbase",
"Recaptcha",
"sabloger",
"sitebuild",
"tailwindcss",
"templ",
"tmpl",
Expand Down
12 changes: 2 additions & 10 deletions crontab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ package crontab

import (
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/cron"
)

func RegisterCronJobs(app *pocketbase.PocketBase) {
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
scheduler := cron.New()

sendPostcards(app, scheduler)
generateSiteMap(app, scheduler)
sendPostcards(app)
generateSiteMap(app)

scheduler.Start()

return nil
})
}
19 changes: 9 additions & 10 deletions crontab/postcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"github.com/blackfyre/wga/assets"
"github.com/blackfyre/wga/utils"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/models"
"github.com/pocketbase/pocketbase/tools/cron"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/mailer"
)

Expand All @@ -21,7 +20,7 @@ import (
// The message is then sent using the mailClient.
// If there is an error sending the postcard, an error message is logged and the function returns.
// Finally, the postcard record is updated using the updatePostcardRecord function.
func sendPostcard(r *models.Record, app *pocketbase.PocketBase, mailClient mailer.Mailer) {
func sendPostcard(r *core.Record, app *pocketbase.PocketBase, mailClient mailer.Mailer) {

recipients := convertCommaSeparatedEmailsToMailAddresses(r.GetString("recipients"))

Expand Down Expand Up @@ -54,7 +53,7 @@ func convertCommaSeparatedEmailsToMailAddresses(emails string) []mail.Address {
// renderMessage renders the email message for a postcard notification.
// It takes a pointer to a models.Record, a mail.Address, and a pointer to a pocketbase.PocketBase as input.
// It returns a pointer to a mailer.Message.
func renderMessage(r *models.Record, rec mail.Address, app *pocketbase.PocketBase) *mailer.Message {
func renderMessage(r *core.Record, rec mail.Address, app *pocketbase.PocketBase) *mailer.Message {
html, err := assets.RenderEmail("postcard:notification", map[string]any{
"SenderName": r.GetString("sender_name"),
"PickUpUrl": utils.AssetUrl("/postcards?p=" + r.GetString("id")),
Expand Down Expand Up @@ -85,12 +84,12 @@ func renderMessage(r *models.Record, rec mail.Address, app *pocketbase.PocketBas
// The function sets the "status" field of the record to "sent" and the "sent_at" field to the current Unix timestamp.
// It then saves the updated record using the SaveRecord method of the pocketbase.PocketBase object.
// If there is an error during the update, it logs the error using the Logger method of the pocketbase.PocketBase object.
func updatePostcardRecord(r *models.Record, app *pocketbase.PocketBase) {
func updatePostcardRecord(r *core.Record, app *pocketbase.PocketBase) {
r.Set("status", "sent")
r.Set("sent_at", time.Now().Unix())

if err := app.Dao().SaveRecord(r); err != nil {
app.Logger().Error("Error updating postcard record", "record_id", r.GetId(), "error", err.Error())
if err := app.Save(r); err != nil {
app.Logger().Error("Error updating postcard record", "record_id", r.Get("id"), "error", err.Error())
}
}

Expand All @@ -109,16 +108,16 @@ func updatePostcardRecord(r *models.Record, app *pocketbase.PocketBase) {
// sendPostcards(app, scheduler)
//
// Note: The sendPostcards function assumes that the necessary dependencies are already imported.
func sendPostcards(app *pocketbase.PocketBase, scheduler *cron.Cron) {
func sendPostcards(app *pocketbase.PocketBase) {

var frequency = os.Getenv("WGA_POSTCARD_FREQUENCY")

if frequency == "" {
frequency = "*/1 * * * *"
}

scheduler.MustAdd("postcards", frequency, func() {
records, err := app.Dao().FindRecordsByFilter(
app.Cron().MustAdd("postcards", frequency, func() {
records, err := app.FindRecordsByFilter(
"postcards", // collection
"status = 'queued'", // filter
"", // sort
Expand Down
5 changes: 2 additions & 3 deletions crontab/sitemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package crontab
import (
"github.com/blackfyre/wga/utils/sitemap"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/tools/cron"
)

func generateSiteMap(app *pocketbase.PocketBase, scheduler *cron.Cron) {
scheduler.MustAdd("sitemap", "0 0 * * *", func() {
func generateSiteMap(app *pocketbase.PocketBase) {
app.Cron().MustAdd("sitemap", "0 0 * * *", func() {
sitemap.GenerateSiteMap(app)
})
}
3 changes: 2 additions & 1 deletion devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
pkgs.git
pkgs.templ
pkgs.air
pkgs.nixd
] ++ lib.optionals (!config.container.isBuilding) [
pkgs.flyctl
pkgs.nil
Expand Down Expand Up @@ -57,7 +58,7 @@
};
};

processes = {
processes = {
watch-js.exec = "bun run build:watch:js";
templ.exec = "templ generate --watch";
# air.exec = "air serve --dev";
Expand Down
137 changes: 84 additions & 53 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,89 +12,120 @@ require (
github.com/klauspost/compress v1.17.11
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61
github.com/microcosm-cc/bluemonday v1.0.27
github.com/pocketbase/dbx v1.10.1
github.com/pocketbase/pocketbase v0.22.22
github.com/pocketbase/dbx v1.11.0
github.com/pocketbase/pocketbase v0.24.4
github.com/sabloger/sitemap-generator v1.3.0
github.com/spf13/cobra v1.8.1
golang.org/x/text v0.21.0
)

require (
cloud.google.com/go/iam v1.2.2 // indirect
cloud.google.com/go/monitoring v1.21.1 // indirect
cloud.google.com/go/storage v1.45.0 // indirect
cel.dev/expr v0.19.0 // indirect
cloud.google.com/go v0.116.0 // indirect
cloud.google.com/go/auth v0.14.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.3.1 // indirect
cloud.google.com/go/monitoring v1.23.0 // indirect
cloud.google.com/go/storage v1.50.0 // indirect
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.48.1 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1 // indirect
github.com/PuerkitoBio/goquery v1.10.1 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2 v1.32.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
github.com/aws/aws-sdk-go-v2/config v1.28.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.42 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.18 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.3 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.66.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.32.3 // indirect
github.com/aws/smithy-go v1.22.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.34.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
github.com/aws/aws-sdk-go-v2/config v1.29.2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.55 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.25 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.54 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.29 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.10 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.74.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.12 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.11 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.10 // indirect
github.com/aws/smithy-go v1.22.2 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/creack/pty v1.1.23 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 // indirect
github.com/creack/pty v1.1.24 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.3 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/ganigeorgiev/fexpr v0.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.32.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
gocloud.dev v0.40.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/image v0.21.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/time v0.9.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/api v0.203.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852 // indirect
modernc.org/libc v1.61.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.33.1 // indirect
modernc.org/strutil v1.2.0 // indirect
google.golang.org/api v0.218.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250127172529-29210b9bc287 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250127172529-29210b9bc287 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
modernc.org/gc/v3 v3.0.0-20250121204235-2db1fde51ea4 // indirect
modernc.org/libc v1.61.10 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.8.2 // indirect
modernc.org/sqlite v1.34.5 // indirect
modernc.org/strutil v1.2.1 // indirect
modernc.org/token v1.1.0 // indirect
)
Loading

0 comments on commit b72af0f

Please sign in to comment.