mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
added hidden 'recipient' parameter to /v2/send endpoint
* some REST API consumers (like the Synology NAS) do not allow to use an array for the recipients. So, in order to support those platforms as well, a 'recipient' string parameter is added. As most users are perfectly fine with the array parameter, the recipient parameter won't be exposed in the Swagger UI. see #428
This commit is contained in:
@@ -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:"<BASE64 ENCODED DATA>,data:<MIME-TYPE>;base64<comma><BASE64 ENCODED DATA>,data:<MIME-TYPE>;filename=<FILENAME>;base64<comma><BASE64 ENCODED DATA>"`
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user