diff --git a/src/api/api.go b/src/api/api.go index fc2f595..b8071bc 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -102,6 +102,7 @@ type SendMessageV1 struct { type SendMessageV2 struct { Number string `json:"number"` Recipients []string `json:"recipients"` + Recipient string `json:"recipient" swaggerignore:"true"` //some REST API consumers (like the Synology NAS) do not support an array as recipients, so we provide this string parameter here as backup. In order to not confuse anyone, the parameter won't be exposed in the Swagger UI (most users are fine with the recipients parameter). Message string `json:"message"` Base64Attachments []string `json:"base64_attachments" example:",data:;base64,data:;filename=;base64"` Sticker string `json:"sticker"` @@ -363,6 +364,13 @@ func (a *Api) SendV2(c *gin.Context) { return } + //some REST API consumers (like the Synology NAS) do not allow to use an array for the recipients. + //so, in order to also support those platforms, a fallback parameter (recipient) is provided. + //this parameter is hidden in the swagger ui in order to not confuse users (most of them are fine with the recipients parameter). + if req.Recipient != "" { + req.Recipients = append(req.Recipients, req.Recipient) + } + if len(req.Recipients) == 0 { c.JSON(400, gin.H{"error": "Couldn't process request - please provide at least one recipient"}) return