1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Small refactoring of modules/private (#15947)

* Use correct variable name.

* doer is never nil here.

* Use status code constants.

* Replaced generic map with concrete struct.

* Fixed windows lint.

* Removed unused method.

* Changed error codes.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
KN4CK3R
2021-06-23 21:38:19 +02:00
committed by GitHub
parent 5930d09096
commit 383ffcfa34
13 changed files with 185 additions and 231 deletions

View File

@@ -23,8 +23,8 @@ import (
// It doesn't wait before each message will be processed
func SendEmail(ctx *context.PrivateContext) {
if setting.MailService == nil {
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"err": "Mail service is not enabled.",
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: "Mail service is not enabled.",
})
return
}
@@ -35,8 +35,8 @@ func SendEmail(ctx *context.PrivateContext) {
json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.NewDecoder(rd).Decode(&mail); err != nil {
log.Error("%v", err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"err": err,
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: err.Error(),
})
return
}
@@ -48,8 +48,8 @@ func SendEmail(ctx *context.PrivateContext) {
if err != nil {
err := fmt.Sprintf("Failed to get user information: %v", err)
log.Error(err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"err": err,
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: err,
})
return
}
@@ -68,8 +68,8 @@ func SendEmail(ctx *context.PrivateContext) {
if err != nil {
err := fmt.Sprintf("Failed to find users: %v", err)
log.Error(err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"err": err,
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: err,
})
return
}