summaryrefslogtreecommitdiff
path: root/controllers/mail.go
blob: da2adf29273777478727403c6e4644ca09aaee8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package controllers

import (
	"lain/repository"
	"lain/session"
	"lain/utils/meta"
	"lain/utils/shortcuts"

	"github.com/gofiber/fiber/v2"
)

func Mailbox(context *fiber.Ctx) error {
	folderPath := context.Params("*", "inbox")
	if folderPath == "" {
		folderPath = "inbox"
	}

	email, err := session.GetSessionEmail(context)
	if err != nil {
		return InternalServerError(context, err)
	}

	folders := repository.GetFolders(email, folderPath)
	displayName := repository.GetFolderDisplayName(email, folderPath)

	emails := []fiber.Map{}

	meta.SetPageTitle(context, displayName)

	return shortcuts.Render(context, "mail/folder", fiber.Map{
		"Folders": folders,
		"Emails":  emails,
		"Email":   nil,
	})
}