summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
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,
})
}