1 parent
e194d6ecfd
commit
fcc863e8b8
18 files changed
+334
-306
No files matched your search
@@ -3,6 +3,7 @@ package email
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/services/group"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -11,8 +12,9 @@ import (
|
||||
)
|
||||
|
||||
type moveRequest struct {
|
||||
GroupId int `json:"group_id"`
|
||||
IDs []int `json:"ids"`
|
||||
GroupId int `json:"group_id"`
|
||||
GroupName string `json:"group_name"`
|
||||
IDs []int `json:"ids"`
|
||||
}
|
||||
|
||||
func Move(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
@@ -31,7 +33,13 @@ func Move(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if !group.MoveMailToGroup(ctx, reqData.IDs, reqData.GroupId) {
|
||||
if name, ok := models.GroupCodeToName[reqData.GroupId]; ok {
|
||||
err := group.Move2DefaultBox(ctx, reqData.IDs, name)
|
||||
if err != nil {
|
||||
response.NewErrorResponse(response.ServerError, "Error", err.Error()).FPrint(w)
|
||||
return
|
||||
}
|
||||
} else if !group.MoveMailToGroup(ctx, reqData.IDs, reqData.GroupId) {
|
||||
response.NewErrorResponse(response.ServerError, "Error", "").FPrint(w)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/Jinnrry/pmail/dto"
|
||||
"github.com/Jinnrry/pmail/dto/response"
|
||||
"github.com/Jinnrry/pmail/i18n"
|
||||
"github.com/Jinnrry/pmail/models"
|
||||
"github.com/Jinnrry/pmail/services/group"
|
||||
"github.com/Jinnrry/pmail/utils/array"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
@@ -14,8 +15,15 @@ import (
|
||||
)
|
||||
|
||||
func GetUserGroupList(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
defaultGroup := []*models.Group{
|
||||
{models.INBOX, i18n.GetText(ctx.Lang, "inbox"), 0, 0, "/"},
|
||||
{models.Junk, i18n.GetText(ctx.Lang, "junk"), 0, 0, "/"},
|
||||
{models.Deleted, i18n.GetText(ctx.Lang, "deleted"), 0, 0, "/"},
|
||||
}
|
||||
|
||||
infos := group.GetGroupList(ctx)
|
||||
response.NewSuccessResponse(infos).FPrint(w)
|
||||
|
||||
response.NewSuccessResponse(append(defaultGroup, infos...)).FPrint(w)
|
||||
}
|
||||
|
||||
func GetUserGroup(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
Reference in new issue
Block a user