SetPipeWebhook calls the pipe's chat platform API to register the webhook URL. @Title SetPipeWebhook @Tag Pipe API @Description set webhook for a pipe @Param id query string true "The id of the pipe (owner/name)" @Success 200 {object} controllers.Response The Response object @router /api/set-pipe-we
()
| 165 | // @Success 200 {object} controllers.Response The Response object |
| 166 | // @router /api/set-pipe-webhook [post] |
| 167 | func (c *ApiController) SetPipeWebhook() { |
| 168 | id := c.Input().Get("id") |
| 169 | |
| 170 | pipe, err := object.GetPipe(id) |
| 171 | if err != nil { |
| 172 | c.ResponseError(err.Error()) |
| 173 | return |
| 174 | } |
| 175 | if pipe == nil { |
| 176 | c.ResponseError("pipe not found") |
| 177 | return |
| 178 | } |
| 179 | |
| 180 | pipeObj, err := pipe.GetProvider(c.GetAcceptLanguage()) |
| 181 | if err != nil { |
| 182 | c.ResponseError(err.Error()) |
| 183 | return |
| 184 | } |
| 185 | |
| 186 | if pipe.Domain == "" { |
| 187 | c.ResponseError("Domain is not set on this pipe") |
| 188 | return |
| 189 | } |
| 190 | |
| 191 | webhookUrl := fmt.Sprintf("%s/api/chat-webhook/%s/%s", pipe.Domain, pipepkg.NormalizeType(pipe.Type), pipe.Name) |
| 192 | if err = pipeObj.SetWebhook(webhookUrl); err != nil { |
| 193 | c.ResponseError(err.Error()) |
| 194 | return |
| 195 | } |
| 196 | |
| 197 | c.ResponseOk(webhookUrl) |
| 198 | } |
| 199 | |
| 200 | // ChatTest sends a test message through the pipe to verify the full pipeline. |
| 201 | // @Title ChatTest |
nothing calls this directly
no test coverage detected