fix(routes): align whatsapp call ids

This commit is contained in:
2026-06-07 13:04:27 +08:00
parent 5062acec61
commit 7ea4bf9362
7 changed files with 53 additions and 51 deletions
@@ -25,7 +25,7 @@ func NewWhatsAppCallHandler(svc *service.WhatsAppCallService) *WhatsAppCallHandl
}
// Show returns a Chatwoot WhatsApp call payload.
// GET /api/v1/accounts/:account_id/whatsapp_calls/:call_id
// GET /api/v1/accounts/:account_id/whatsapp_calls/:id
func (h *WhatsAppCallHandler) Show(c *gin.Context) {
accountID, callID, ok := h.parseAccountCallParams(c)
if !ok {
@@ -72,7 +72,7 @@ func (h *WhatsAppCallHandler) Initiate(c *gin.Context) {
}
// Accept forwards an SDP answer to Meta and returns the updated call payload.
// POST /api/v1/accounts/:account_id/whatsapp_calls/:call_id/accept
// POST /api/v1/accounts/:account_id/whatsapp_calls/:id/accept
func (h *WhatsAppCallHandler) Accept(c *gin.Context) {
accountID, callID, ok := h.parseAccountCallParams(c)
if !ok {
@@ -91,7 +91,7 @@ func (h *WhatsAppCallHandler) Accept(c *gin.Context) {
}
// Reject rejects a ringing WhatsApp call.
// POST /api/v1/accounts/:account_id/whatsapp_calls/:call_id/reject
// POST /api/v1/accounts/:account_id/whatsapp_calls/:id/reject
func (h *WhatsAppCallHandler) Reject(c *gin.Context) {
accountID, callID, ok := h.parseAccountCallParams(c)
if !ok {
@@ -106,7 +106,7 @@ func (h *WhatsAppCallHandler) Reject(c *gin.Context) {
}
// Terminate terminates an active or ringing WhatsApp call.
// POST /api/v1/accounts/:account_id/whatsapp_calls/:call_id/terminate
// POST /api/v1/accounts/:account_id/whatsapp_calls/:id/terminate
func (h *WhatsAppCallHandler) Terminate(c *gin.Context) {
accountID, callID, ok := h.parseAccountCallParams(c)
if !ok {
@@ -121,7 +121,7 @@ func (h *WhatsAppCallHandler) Terminate(c *gin.Context) {
}
// UploadRecording attaches an audio recording to the linked voice_call message.
// POST /api/v1/accounts/:account_id/whatsapp_calls/:call_id/upload_recording
// POST /api/v1/accounts/:account_id/whatsapp_calls/:id/upload_recording
func (h *WhatsAppCallHandler) UploadRecording(c *gin.Context) {
accountID, callID, ok := h.parseAccountCallParams(c)
if !ok {
@@ -146,8 +146,8 @@ func (h *WhatsAppCallHandler) parseAccountCallParams(c *gin.Context) (uint, uint
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid account id")
return 0, 0, false
}
callID, err := parseUintParam(c, "call_id")
if err != nil {
callID, err := parseUintAnyParam(c, "call_id", "id")
if err != nil || callID == 0 {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid call id")
return 0, 0, false
}