aboutsummaryrefslogtreecommitdiff
path: root/services/mailbox.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-07 18:42:40 +0530
committerBobby <[email protected]>2026-03-07 18:42:40 +0530
commit96c136f046d78c51210927e61483a36a220fedcb (patch)
tree8f5baf294d92ec3bc503bd02f4a08871874f048d /services/mailbox.go
parent6bc2ef7a8972547f10a5a8f50269b0e6b487a580 (diff)
downloaddove-96c136f046d78c51210927e61483a36a220fedcb.tar.xz
dove-96c136f046d78c51210927e61483a36a220fedcb.zip
Refactor dashboard and mailboxes pages to integrate services for data retrieval
- Updated `Dashboard` function to use `services.Overview()` for rendering overview data. - Enhanced `Mailboxes` function to include pagination, sorting, and search functionality using `services.ListMailboxes()`. - Modified `Users` function to implement pagination, sorting, and search with `services.ListUsers()`. Revamped templates for mailboxes and users - Updated `mailboxes.htmx.django` to display mailbox items dynamically with total count. - Enhanced `users.htmx.django` to show user details and total count, with improved layout for user information. Introduced new response types and constants - Added `PaginatedResponse` type in `types/response.go` for consistent pagination responses. - Introduced constants for pagination in `utils/meta/constants.go`. Implemented email processing and storage services - Created `services/email.go` for processing incoming emails and storing them in the database. - Added email parsing utilities in `utils/email` for handling email content and attachments. Established repository functions for mailboxes, users, and emails - Created repository functions in `repositories` for managing mailboxes, users, and emails, including listing and searching capabilities. Refactored SMTP server functions - Updated SMTP server handling in `utils/smtp` to streamline session management and message processing. - Removed obsolete storage functions and integrated email processing directly into the SMTP session. Added new message constants for better logging and error handling - Introduced message constants in `messages/email.go` and `messages/mailbox.go` for improved clarity in logs.
Diffstat (limited to 'services/mailbox.go')
-rw-r--r--services/mailbox.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/services/mailbox.go b/services/mailbox.go
new file mode 100644
index 0000000..b84e19b
--- /dev/null
+++ b/services/mailbox.go
@@ -0,0 +1,26 @@
+package services
+
+import (
+ "dove/models"
+ "dove/repositories"
+ "dove/types"
+ "dove/utils/meta"
+)
+
+func ListMailboxes(pagination meta.Pagination, sorting meta.Sorting, search string) types.PaginatedResponse {
+ mailboxes, total := repositories.ListMailboxes(pagination, sorting, search)
+ return pagination.Response(mailboxes, total)
+}
+
+func ResolveMailboxes(recipientAddresses []string) []models.Mailbox {
+ var resolvedMailboxes []models.Mailbox
+
+ for _, address := range recipientAddresses {
+ mailbox := resolveMailbox(address)
+ if mailbox != nil {
+ resolvedMailboxes = append(resolvedMailboxes, *mailbox)
+ }
+ }
+
+ return resolvedMailboxes
+}