Commit Graph

113 Commits

Author SHA1 Message Date
07117ba35e No longer required. 2025-10-24 13:19:55 +01:00
ac1f6e9399 refactor(template): delegate handler-level RenderError to helpers package
- Moved core RenderError logic to internal/helpers/template/error.go
- Added thin wrapper method in internal/handlers/template/error.go
- Simplified function signature (no config args, uses InitSiteMeta)
- Preserved architecture: handlers own HTTP layer, helpers supply logic
2025-10-24 13:15:12 +01:00
fb07c4a5eb Refactoring for Gin, NoSurf and SCS continues. 2025-10-24 13:08:53 +01:00
7276903733 refactor(config): move Config struct from business layer to platform/config
Moved the Config struct (previously in internal/models/config.go) into internal/platform/config/types.go to align with clean architecture principles.

This change decouples runtime/infrastructure configuration from domain models:
- Configuration is an application/platform concern, not part of the business domain.
- Prevents potential circular imports between models and platform packages.
- Simplifies future integration with platform components (SCS sessions, CSRF, DB).

No functional changes to configuration loading structure and JSON schema remain the same; only the package location and imports were updated.
2025-10-24 08:35:39 +01:00
0f60be448d Refactoring continues. 2025-10-23 21:51:15 +01:00
82f457c5a4 New packages for MySQL. 2025-10-23 19:53:06 +01:00
b098915ab9 Update import paths 2025-10-23 19:51:28 +01:00
21ebc9c34b Refactor and remove sqlite and replace with MySQL 2025-10-23 18:43:31 +01:00
d53e27eea8 Switching to MySQL 2025-10-22 22:43:35 +01:00
752db0b89d New statistics related models and handlers. 2025-10-22 20:58:25 +01:00
8d06a7a962 Remove log output and updated comment 2025-10-22 20:57:03 +01:00
7597fff8b1 routes.SetupStatisticsRoutes 2025-10-22 20:56:04 +01:00
58dd313703 Forgot to add draw IDs to tables. 2025-10-20 14:48:33 +01:00
e0a2e5430e Change greeting to include user related dropdown items. 2025-04-23 15:30:23 +01:00
7d26f6cf48 Update footer so copyright start year is displayed and evaluated. 2025-04-23 15:30:02 +01:00
0634876b75 Add in context to dashboard for user to topbar loads all items & refactor for clarity of variable extraction. 2025-04-23 15:29:34 +01:00
b5f1b17684 Fix loading of tickets missing range class. 2025-04-23 11:54:45 +01:00
f9853c921d Refactoring finalised ... I think. 2025-04-23 11:30:03 +01:00
e938828a8c fix loading ofr login form and redirects. 2025-04-23 10:06:55 +01:00
2ce810a4dd Refactoring cont. 2025-04-23 09:44:19 +01:00
5c3a847900 Massive refactor! 2025-04-22 23:26:11 +01:00
05bb05d45c Move admin.go this is a storage task, updated routes to use proection 2025-04-16 10:41:06 +01:00
7f91771166 Implement a stronger, reusable session timeout 2025-04-16 10:32:34 +01:00
f7e9fe7794 make shutting down graceful 2025-04-16 10:24:54 +01:00
2440b3a668 Rewiring CSRF protection and movign some functionality to the bootstrapping stage. 2025-04-16 09:50:58 +01:00
4bb3b58ddb Bootstrapped the creation and loading of session keys to lighten main. 2025-04-16 08:21:02 +01:00
0a21973237 rework to lighten the main, refactor wrappers. Rehandle csrf and pull config items. 2025-04-15 22:19:55 +01:00
0a5d61ea1e Re-work loading of configuration, introduce a loader for start up & and custom logging wrapper. 2025-04-15 21:10:57 +01:00
d7c15141b8 Been too long since i did anything, can't remember what the hell is in all this.... 2025-04-15 20:56:21 +01:00
152c5cb18c Add Syndicate Invite Token System (Secure Links)
- Added route + handler: GenerateInviteLinkHandler to create signed tokens
- Added handler: JoinSyndicateWithTokenHandler to join using invite token
- Integrated secure token generation via helpers.GenerateSecureToken()
- Created DB model: syndicate_invite_tokens (assumed pre-existing)
- Updated syndicate view template to allow managers to generate links
- Flash messaging for invite success/failure
- Invite links are scoped to manager role and valid for 48 hours
2025-04-04 22:33:40 +01:00
8b02a3137d Filter out syndicates where the user is both the owner and a member in syndicate veiw. 2025-04-04 11:19:45 +01:00
f6350b1d7f more link fixes. 2025-04-04 11:12:54 +01:00
292db01011 Fix issue creating syndicates, accepted should not be set when creating. 2025-04-04 11:10:15 +01:00
02300c69d8 Fix Syndicate paths. 2025-04-04 10:57:06 +01:00
22fbf59157 Forgot to remove handler. 2025-04-04 10:30:28 +01:00
ef4478e8a6 Added syndicate creation and invite logic
- Implemented `CreateSyndicate` with transaction support
- Added `InviteToSyndicate` with membership check and invite insert
- Created syndicate invite model and DB logic for accepting/declining
- Ensured consistent error handling with `fmt.Errorf`
- Cleaned up unused invite handlers/routes
2025-04-04 10:26:24 +01:00
df6608dda5 forgot to stage 2025-04-02 23:53:40 +01:00
053ccf3845 **Untested! ** Add restore functionality for archived messages
- Added `RestoreMessageHandler` and route at `/account/messages/restore`
- Updated `users_messages` table to support `archived_at` reset
- Added restore button to archived messages template
- Ensures archived messages can be moved back into inbox
2025-04-02 23:53:29 +01:00
db5352bc9c Add restore functionality for archived messages
- Added `RestoreMessageHandler` and route at `/account/messages/restore`
- Updated `users_messages` table to support `archived_at` reset
- Added restore button to archived messages template
- Ensures archived messages can be moved back into inbox
2025-04-02 22:18:02 +01:00
dd83081271 Added full message handling system with archive view, pagination, and send support
- Implemented message inbox and archived messages view
- Added pagination logic to both inbox and archive handlers
- Integrated message sending functionality with CSRF protection
- Updated schema to include `archived_at` timestamp
- Included archive button and logic with feedback flash messaging
- Fixed message dropdown routing and rendering in topbar
- Cleaned up template load paths and error handling
2025-04-02 21:29:54 +01:00
e3428911b9 Messages: Add archive (soft-delete) support + dropdown UI polish
- Implemented `/account/messages/archive` route for soft-archiving messages
- Added `is_archived` flag to `users_messages` schema and model
- Topbar dropdown now reflects accurate unread message count
- Fixed missing route registration for archive handler
- Improved message visibility checks to prevent access violations
- Placeholder for rate-limit (429) error page rendering identified
2025-04-02 17:15:57 +01:00
2fd053777d Feature: complete message inbox, view, and topbar integration
Added users_messages schema with correct field naming (senderId, recipientId)

Implemented message count and recent message fetch via storage.GetMessageCount and GetRecentMessages

Fixed field mismatches in SQL queries (recipientId vs recipient_id)

Displayed unread message badge in topbar with truncation for body preview

Linked messages in dropdown to full view (/account/messages/read?id=...)

Added fallback handling for unauthorized/invalid message access

Cleaned up BuildTemplateData to support full message context

Ensured CSRF/session/user context remains intact throughout
2025-04-02 13:41:51 +01:00
b630296b8c Add message system (inbox, read view, dropdown) and truncate helper
Implemented message retrieval and read logic in storage layer

Added handlers for inbox and individual message view

Integrated messages into topbar dropdown with unread badge

Added truncate helper to template functions

Created new templates: messages/index.html and messages/read.html

Fixed missing template function error in topbar rendering
2025-04-02 11:56:11 +01:00
ab1d9abc72 Refactor: Recover middleware now uses RenderError + add full notifications view
- Replaced http.Error with helpers.RenderError in Recover middleware
- Custom 500.html now rendered with layout and topbar on panic
- RenderError gracefully checks template existence and falls back to plain response
- Added /account/notifications full view page (index)
- Linked "Back to notifications" from notification read view
- Fixed typo in template path for notifications/index.html
- Improved layout consistency across error and account pages
2025-04-02 09:54:20 +01:00
2498b33a9c Refactor: Centralize template loading and improve error handling
- Introduced helpers.LoadTemplateFiles() for consistent layout + topbar rendering
- Replaced repeated template.ParseFiles() calls across handlers
- Created generic RenderError(w, r, statusCode) helper
- Replaced old Render403 with flexible RenderError
- Updated AdminOnly middleware to render 403 errors with context
- Added 500.html template for graceful panic fallback
- Prepared structure for future error codes (404, 429, etc.)
2025-04-02 09:12:13 +01:00
f5653f737d Delete synlotto.db 2025-04-01 22:22:46 +00:00
e5bf12ad77 Feature: Full notification read view with conditional mark-as-read logic
- Added dedicated route and view for reading individual notifications (/account/notifications/read)
- Ensured notification is only marked as read if it hasn't already been
- Updated Notification model to use Subject and Body fields
- Fixed field references in templates (Title → Subject, Message → Body)
- Updated topbar dropdown to use correct field names and display logic
- Gracefully handle "notification not found" cases in template output
- Ensured consistent template parsing with layout and topbar inclusion
- Improved error logging for better diagnosis
2025-04-01 23:08:58 +01:00
06e647d00f Feature: Add account-protected route to mark notifications as read
- Created /account/notifications/read endpoint secured by session middleware
- Ensured users can only mark their own notifications as read
- Updated dropdown links to point to /account/notifications/read?id={id}
- Improved notification security by matching user_id in DB update
- Added redirect flow to full notifications page after marking read
- Logged DB errors to assist debugging
2025-04-01 22:12:41 +01:00
1e372da57d adjust count mechanism. 2025-04-01 21:39:57 +01:00
d5b953475c schema update, no sender name required. 2025-04-01 21:38:08 +01:00