Commit 85aa3d66 authored by Jesús Espino's avatar Jesús Espino Committed by Joram Wilander

MM-11034: Reply properly to incomming webhooks on errors (#9010)

parent 2d7cd02a
......@@ -157,7 +157,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c.Err.IsOAuth = false
}
if IsApiCall(c.App, r) || len(r.Header.Get("X-Mobile-App")) > 0 {
if IsApiCall(c.App, r) || IsWebhookCall(c.App, r) || len(r.Header.Get("X-Mobile-App")) > 0 {
w.WriteHeader(c.Err.StatusCode)
w.Write([]byte(c.Err.ToJson()))
} else {
......
......@@ -73,7 +73,13 @@ func Handle404(a *app.App, w http.ResponseWriter, r *http.Request) {
func IsApiCall(a *app.App, r *http.Request) bool {
subpath, _ := utils.GetSubpathFromConfig(a.Config())
return strings.Index(r.URL.Path, path.Join(subpath, "api")+"/") == 0
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "api")+"/")
}
func IsWebhookCall(a *app.App, r *http.Request) bool {
subpath, _ := utils.GetSubpathFromConfig(a.Config())
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "hooks")+"/")
}
func ReturnStatusOK(w http.ResponseWriter) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment