|
|
@@ -5,14 +5,16 @@ |
|
|
|
package utils |
|
|
|
|
|
|
|
import ( |
|
|
|
api "code.gitea.io/sdk/gitea" |
|
|
|
|
|
|
|
"encoding/json" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/routers/api/v1/convert" |
|
|
|
"code.gitea.io/gitea/routers/utils" |
|
|
|
api "code.gitea.io/sdk/gitea" |
|
|
|
|
|
|
|
"github.com/Unknwon/com" |
|
|
|
) |
|
|
|
|
|
|
@@ -119,8 +121,14 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID |
|
|
|
ctx.Error(422, "", "Missing config option: channel") |
|
|
|
return nil, false |
|
|
|
} |
|
|
|
|
|
|
|
if !utils.IsValidSlackChannel(channel) { |
|
|
|
ctx.Error(400, "", "Invalid slack channel name") |
|
|
|
return nil, false |
|
|
|
} |
|
|
|
|
|
|
|
meta, err := json.Marshal(&models.SlackMeta{ |
|
|
|
Channel: channel, |
|
|
|
Channel: strings.TrimSpace(channel), |
|
|
|
Username: form.Config["username"], |
|
|
|
IconURL: form.Config["icon_url"], |
|
|
|
Color: form.Config["color"], |
|
|
|