Get real mailbox size from dovecot
- Add mail.GetQuota() using doveadm quota get - Fix UserWithQuota response struct - Fix frontend NaN display with Unknown fallback - Update field names to camelCase (usedQuota)
This commit is contained in:
parent
16b6d9df60
commit
c5a9149220
3 changed files with 68 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/imc-vibe/backend/internal/db"
|
||||
"github.com/imc-vibe/backend/internal/mail"
|
||||
)
|
||||
|
||||
type UserHandler struct {
|
||||
|
|
@ -30,6 +31,13 @@ type UpdateUserRequest struct {
|
|||
Quota int64 `json:"quota,omitempty"`
|
||||
}
|
||||
|
||||
type UserWithQuota struct {
|
||||
ID uint `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Quota int64 `json:"quota"`
|
||||
UsedQuota *int64 `json:"usedQuota"`
|
||||
}
|
||||
|
||||
func (h *UserHandler) List(c *gin.Context) {
|
||||
domainName := c.Param("name")
|
||||
if domainName == "" {
|
||||
|
|
@ -61,7 +69,22 @@ func (h *UserHandler) List(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
Success(c, users)
|
||||
result := make([]UserWithQuota, len(users))
|
||||
for i, user := range users {
|
||||
result[i] = UserWithQuota{
|
||||
ID: user.ID,
|
||||
Email: user.Email,
|
||||
Quota: user.Quota,
|
||||
}
|
||||
|
||||
quota, err := mail.GetQuota(user.Email)
|
||||
if err == nil && quota != nil {
|
||||
result[i].Quota = quota.Limit
|
||||
result[i].UsedQuota = "a.Used
|
||||
}
|
||||
}
|
||||
|
||||
Success(c, result)
|
||||
}
|
||||
|
||||
func (h *UserHandler) Get(c *gin.Context) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue