Commit graph

30 commits

Author SHA1 Message Date
f76bdd2656 Fix Send Reminder emailing only sender, not players
SendEmail never read Email.BccAddress, so the player recipients
attached as Bcc were silently dropped from the SMTP envelope and
only the hardcoded To address (the sender) ever received the mail.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 21:50:21 -04:00
5f1a48b1be Log error when sendEmailHandler fails to send an email
Send Reminder failures were silently swallowed, only surfacing in the
HTTP response and never in the application log, unlike the GM
notification email flows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-04 21:33:09 -04:00
ee4581ed7e Send GM notification email asynchronously
Page response no longer waits on SMTP — status update persists and
returns immediately; email fires in a background goroutine.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 20:41:24 -04:00
eb930b0794 Improve email config error to name the missing variable(s)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 20:37:39 -04:00
48e7acab83 Add CGO_ENABLED=0 to Linux cross-compile targets; add Dockerfile
CGO_ENABLED=0 ensures a fully static binary that runs in Alpine without
glibc. Dockerfile copies both binaries into Alpine, installs cronie for
the awp-cli cron job, and mounts runtime data (players.json, static/,
logs/) from the host at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 20:33:55 -04:00
fc5c986141 Consolidate log file env vars: AWP_LOG_FILE (web) and AWP_CLI_LOG_FILE (CLI)
Removes the duplicate log setup from cli/cmd/root.go that was reading
AWP_LOG_FILE — log file config now lives only in each binary's main.go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 19:57:46 -04:00
01d2cae282 Send GM status update email on every attendance change
When a player's attendance is updated — either via email (awp-cli check)
or via the web toggle — an email is sent to the GM with:
  - who changed, what they changed to, and how (email or the site)
  - a summary count of attending/not attending/no response
  - the full current player status list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 19:07:51 -04:00
3426d5ad3d Log partial email body read errors instead of silently ignoring
io.ReadAll errors are unlikely for short yes/no replies but worth
logging for diagnosability. Processing continues with whatever bytes
were read to remain resilient.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:44:33 -04:00
bda5ef1fcf Fix PORT env var overwriting the 8080 fallback
The old code set port='8080' then unconditionally overwrote it with
os.Getenv("PORT"), which returns "" when unset, causing the server
to bind to ':' instead of ':8080'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:39:19 -04:00
d48adbc3f5 Add missing return after redirect in /login handler
Without the return, execution fell through to render the login page
into the same response after writing the redirect header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:38:19 -04:00
dcf1230414 Handle GenerateJWTAndStoreInCookie error in setupHandler
A JWT signing failure was silently ignored, leaving the user on the
setup page with no auth cookie and no explanation for subsequent 401s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:35:18 -04:00
e6e8d255bd Return IMAP search error instead of swallowing it
A search failure was logged but execution continued, silently returning
'no emails' to the caller. This masked the most likely cause of the
polling not working. Error now propagates so the caller can log and
handle it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:34:27 -04:00
3aa0c71c32 Log and return PersistSession error in check command
A failed file write was silently ignored, causing attendance updates
to be lost with no indication of failure to cron or the log.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:33:32 -04:00
c39bd3ec53 Add mutex to protect players.json and fix URL-encode player names
Concurrent HTTP requests and the cron job could race on the file,
causing lost updates or torn writes. A package-level RWMutex now
guards all reads and writes.

Also URL-encodes player names in ToggleUrl to prevent query-parameter
injection from names containing '&' or '='.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:31:18 -04:00
3684baa2f5 Replace log.Fatal in IMAP fetch goroutine with error channel
log.Fatal called os.Exit from a goroutine, bypassing deferred cleanup
and crashing the process on any transient fetch error. Errors now
propagate back to the caller via a buffered channel. Also adds a drain
defer so the goroutine can always exit if the consumer returns early.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:30:27 -04:00
c509641f59 Guard against empty From header in IMAP message fetch
Bounce messages and MAILER-DAEMON notices can have no From address,
causing a panic on the bare [0] index access.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:29:05 -04:00
2d6436dca6 Add missing auth check to saveSetupHandler
Consistent with all other mutation handlers which already guard with
ValidateJWTFromCookie.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:23:27 -04:00
07e67d4684 Make godotenv.Load() best-effort to support containerized deployments
A missing .env file no longer causes a fatal error. Env vars can now
come from the container environment (Docker/systemd) or a .env file
interchangeably.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 18:22:37 -04:00
6371d5136f Rename USERNAME/PASSWORD env vars to EMAIL_USERNAME/EMAIL_PASSWORD
Avoids collision with standard Linux shell variables that would cause
silent authentication failures against the IMAP server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 16:56:13 -04:00
713a96501d Add error logging to awp-cli with configurable log file
- Route all log output to AWP_LOG_FILE (from .env) if set, else stderr
- Log errors explicitly before returning so they appear in the log file
- Replace log.Fatal in fetch.go with proper error return so callers control logging
- Remove chatty success/no-op log lines that would bloat cron log files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 16:45:56 -04:00
04f687a278 Fix build errors and upgrade templ to v0.3.1020
- Add missing bcc argument to NewEmail call in pkg/email/fetch.go
- Upgrade github.com/a-h/templ from v0.3.833 to v0.3.1020 to match generator
- Add player management routes (add/delete/edit) and playershandler
- Update templates and loaddata with pending changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 20:05:53 -04:00
4a778b1dc0 Add uncommitted changes before migration 2025-12-21 12:25:17 -05:00
a36ef9d8f6 Fixing templates 2024-04-28 15:11:16 -04:00
3b30333835 Sends notice to player if they send in an email that the system can't process. 2024-01-31 11:22:32 -05:00
cb7835fb45 Updated to send GM notifications when player email found 2024-01-29 14:10:15 -05:00
3e1e091356 Fixed bug where looks for attending status in 1st line, but not always there 2024-01-21 01:01:38 -05:00
1bbbbd0dd3 Spelling error in filename 2024-01-20 22:20:22 -05:00
605d1c69ec Updated README and example players.json 2024-01-20 22:19:42 -05:00
9f894671b0 Full app, v1.0. Contains web app and cli. 2024-01-20 21:45:53 -05:00
Harry Culpan
9f310f98db
Initial commit 2024-01-17 10:11:38 -05:00