summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-12-23 18:36:26 +0530
committerBobby <[email protected]>2025-12-23 18:36:26 +0530
commit17b250cd4722ba281343b35b85fb645ffefedcf8 (patch)
tree7345787eaeba82799ac9f50562a377ed953e2c2a /controllers
parent5f691c04754ffd459b2ba0e434dc17585ba7c66c (diff)
downloadlain-17b250cd4722ba281343b35b85fb645ffefedcf8.tar.xz
lain-17b250cd4722ba281343b35b85fb645ffefedcf8.zip
email model and syncing and showing emails
Diffstat (limited to 'controllers')
-rw-r--r--controllers/mail.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/controllers/mail.go b/controllers/mail.go
index da2adf2..36166ce 100644
--- a/controllers/mail.go
+++ b/controllers/mail.go
@@ -1,6 +1,7 @@
package controllers
import (
+ "lain/models"
"lain/repository"
"lain/session"
"lain/utils/meta"
@@ -20,10 +21,23 @@ func Mailbox(context *fiber.Ctx) error {
return InternalServerError(context, err)
}
+ prefs := context.Locals("Preferences").(*models.Preferences)
+
folders := repository.GetFolders(email, folderPath)
displayName := repository.GetFolderDisplayName(email, folderPath)
- emails := []fiber.Map{}
+ page := context.QueryInt("page", 1)
+ if page < 1 {
+ page = 1
+ }
+
+ limit := prefs.EmailsPerPage
+ offset := (page - 1) * limit
+
+ emails, err := repository.GetEmails(email, folderPath, limit, offset)
+ if err != nil {
+ emails = []fiber.Map{}
+ }
meta.SetPageTitle(context, displayName)
@@ -31,5 +45,6 @@ func Mailbox(context *fiber.Ctx) error {
"Folders": folders,
"Emails": emails,
"Email": nil,
+ "Page": page,
})
}