Some checks are pending
Security Checks / security (push) Waiting to run
统一 frontend、backend、test、test-log 和 out 目录,更新构建、部署及测试入口;纳入配置管理兼容与首次安全引导修复;排除本机配置、密钥和测试产物。
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package email
|
|
|
|
import (
|
|
"git.pcux.cn/xuans/Smail/dto/response"
|
|
"git.pcux.cn/xuans/Smail/services/detail"
|
|
"git.pcux.cn/xuans/Smail/utils/context"
|
|
log "github.com/sirupsen/logrus"
|
|
"net/http"
|
|
)
|
|
|
|
type markReadRequest struct {
|
|
IDs []int `json:"ids"`
|
|
}
|
|
|
|
func MarkRead(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
|
var reqData markReadRequest
|
|
if err := decodeEmailJSONRequest(w, req, &reqData, maxEmailJSONRequestBytes); err != nil {
|
|
log.WithContext(ctx).WithError(err).Info("invalid email read request")
|
|
response.NewErrorResponse(response.ParamsError, "\u53c2\u6570\u9519\u8bef", "").FPrint(w)
|
|
return
|
|
}
|
|
|
|
if len(reqData.IDs) <= 0 || len(reqData.IDs) > maxEmailOperationIDs {
|
|
response.NewErrorResponse(response.ParamsError, "ID错误", "").FPrint(w)
|
|
return
|
|
}
|
|
|
|
for _, id := range reqData.IDs {
|
|
if _, err := detail.GetEmailDetail(ctx, id, true); err != nil {
|
|
log.WithContext(ctx).WithError(err).Error("mark email read failed")
|
|
response.NewErrorResponse(response.ServerError, "\u66f4\u65b0\u90ae\u4ef6\u5931\u8d25", "").FPrint(w)
|
|
return
|
|
}
|
|
}
|
|
response.NewSuccessResponse("success").FPrint(w)
|
|
|
|
}
|