mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-26 14:44:15 +00:00
Merge branch 'master' into rootless_s6
This commit is contained in:
commit
cbefcb2ecd
@ -156,4 +156,6 @@ There are a bunch of environmental variables that can be set inside the docker c
|
|||||||
|
|
||||||
* `JSON_RPC_IGNORE_ATTACHMENTS`: When set to `true`, attachments are not automatically downloaded in json-rpc mode (default: `false`)
|
* `JSON_RPC_IGNORE_ATTACHMENTS`: When set to `true`, attachments are not automatically downloaded in json-rpc mode (default: `false`)
|
||||||
* `JSON_RPC_IGNORE_STORIES`: When set to `true`, stories are not automatically downloaded in json-rpc mode (default: `false`)
|
* `JSON_RPC_IGNORE_STORIES`: When set to `true`, stories are not automatically downloaded in json-rpc mode (default: `false`)
|
||||||
|
* `JSON_RPC_IGNORE_AVATARS`: When set to `true`, avatars are not automatically downloaded in json-rpc mode (default: `false`)
|
||||||
|
* `JSON_RPC_IGNORE_STICKERS`: When set to `true`, sticker packs are not automatically downloaded in json-rpc mode (default: `false`)
|
||||||
* `JSON_RPC_TRUST_NEW_IDENTITIES`: Choose how to trust new identities in json-rpc mode. Supported values: `on-first-use`, `always`, `never`. (default: `on-first-use`)
|
* `JSON_RPC_TRUST_NEW_IDENTITIES`: Choose how to trust new identities in json-rpc mode. Supported values: `on-first-use`, `always`, `never`. (default: `on-first-use`)
|
||||||
|
|||||||
@ -670,6 +670,8 @@ func StringToBool(input string) bool {
|
|||||||
// @Param timeout query string false "Receive timeout in seconds (default: 1)"
|
// @Param timeout query string false "Receive timeout in seconds (default: 1)"
|
||||||
// @Param ignore_attachments query string false "Specify whether the attachments of the received message should be ignored" (default: false)"
|
// @Param ignore_attachments query string false "Specify whether the attachments of the received message should be ignored" (default: false)"
|
||||||
// @Param ignore_stories query string false "Specify whether stories should be ignored when receiving messages" (default: false)"
|
// @Param ignore_stories query string false "Specify whether stories should be ignored when receiving messages" (default: false)"
|
||||||
|
// @Param ignore_avatars query string false "Specify whether avatar downloads should be ignored when receiving messages" (default: false)"
|
||||||
|
// @Param ignore_stickers query string false "Specify whether sticker pack downloads should be ignored when receiving messages" (default: false)"
|
||||||
// @Param max_messages query string false "Specify the maximum number of messages to receive (default: unlimited)". Not available in json-rpc mode.
|
// @Param max_messages query string false "Specify the maximum number of messages to receive (default: unlimited)". Not available in json-rpc mode.
|
||||||
// @Param send_read_receipts query string false "Specify whether read receipts should be sent when receiving messages" (default: false)"
|
// @Param send_read_receipts query string false "Specify whether read receipts should be sent when receiving messages" (default: false)"
|
||||||
// @Router /v1/receive/{number} [get]
|
// @Router /v1/receive/{number} [get]
|
||||||
@ -718,13 +720,25 @@ func (a *Api) Receive(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignoreAvatars := c.DefaultQuery("ignore_avatars", "false")
|
||||||
|
if ignoreAvatars != "true" && ignoreAvatars != "false" {
|
||||||
|
c.JSON(400, Error{Msg: "Couldn't process request - ignore_avatars parameter needs to be either 'true' or 'false'"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ignoreStickers := c.DefaultQuery("ignore_stickers", "false")
|
||||||
|
if ignoreStickers != "true" && ignoreStickers != "false" {
|
||||||
|
c.JSON(400, Error{Msg: "Couldn't process request - ignore_stickers parameter needs to be either 'true' or 'false'"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sendReadReceipts := c.DefaultQuery("send_read_receipts", "false")
|
sendReadReceipts := c.DefaultQuery("send_read_receipts", "false")
|
||||||
if sendReadReceipts != "true" && sendReadReceipts != "false" {
|
if sendReadReceipts != "true" && sendReadReceipts != "false" {
|
||||||
c.JSON(400, Error{Msg: "Couldn't process request - send_read_receipts parameter needs to be either 'true' or 'false'"})
|
c.JSON(400, Error{Msg: "Couldn't process request - send_read_receipts parameter needs to be either 'true' or 'false'"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonStr, err := a.signalClient.Receive(number, timeoutInt, StringToBool(ignoreAttachments), StringToBool(ignoreStories), maxMessagesInt, StringToBool(sendReadReceipts))
|
jsonStr, err := a.signalClient.Receive(number, timeoutInt, StringToBool(ignoreAttachments), StringToBool(ignoreStories), StringToBool(ignoreAvatars), StringToBool(ignoreStickers), maxMessagesInt, StringToBool(sendReadReceipts))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, Error{Msg: err.Error()})
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
return
|
return
|
||||||
|
|||||||
@ -993,7 +993,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
|||||||
return ×tamps, nil
|
return ×tamps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) Receive(number string, timeout int64, ignoreAttachments bool, ignoreStories bool, maxMessages int64, sendReadReceipts bool) (string, error) {
|
func (s *SignalClient) Receive(number string, timeout int64, ignoreAttachments bool, ignoreStories bool, ignoreAvatars bool, ignoreStickers bool, maxMessages int64, sendReadReceipts bool) (string, error) {
|
||||||
if s.signalCliMode == JsonRpc {
|
if s.signalCliMode == JsonRpc {
|
||||||
return "", errors.New("Not implemented")
|
return "", errors.New("Not implemented")
|
||||||
} else {
|
} else {
|
||||||
@ -1007,6 +1007,14 @@ func (s *SignalClient) Receive(number string, timeout int64, ignoreAttachments b
|
|||||||
command = append(command, "--ignore-stories")
|
command = append(command, "--ignore-stories")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ignoreAvatars {
|
||||||
|
command = append(command, "--ignore-avatars")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ignoreStickers {
|
||||||
|
command = append(command, "--ignore-stickers")
|
||||||
|
}
|
||||||
|
|
||||||
if maxMessages > 0 {
|
if maxMessages > 0 {
|
||||||
command = append(command, "--max-messages")
|
command = append(command, "--max-messages")
|
||||||
command = append(command, strconv.FormatInt(maxMessages, 10))
|
command = append(command, strconv.FormatInt(maxMessages, 10))
|
||||||
|
|||||||
@ -2043,6 +2043,18 @@ const docTemplate = `{
|
|||||||
"name": "ignore_stories",
|
"name": "ignore_stories",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Specify whether avatar downloads should be ignored when receiving messages",
|
||||||
|
"name": "ignore_avatars",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Specify whether sticker pack downloads should be ignored when receiving messages",
|
||||||
|
"name": "ignore_stickers",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Specify the maximum number of messages to receive (default: unlimited)",
|
"description": "Specify the maximum number of messages to receive (default: unlimited)",
|
||||||
|
|||||||
@ -2040,6 +2040,18 @@
|
|||||||
"name": "ignore_stories",
|
"name": "ignore_stories",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Specify whether avatar downloads should be ignored when receiving messages",
|
||||||
|
"name": "ignore_avatars",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Specify whether sticker pack downloads should be ignored when receiving messages",
|
||||||
|
"name": "ignore_stickers",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Specify the maximum number of messages to receive (default: unlimited)",
|
"description": "Specify the maximum number of messages to receive (default: unlimited)",
|
||||||
|
|||||||
@ -1916,6 +1916,16 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
name: ignore_stories
|
name: ignore_stories
|
||||||
type: string
|
type: string
|
||||||
|
- description: Specify whether avatar downloads should be ignored when receiving
|
||||||
|
messages
|
||||||
|
in: query
|
||||||
|
name: ignore_avatars
|
||||||
|
type: string
|
||||||
|
- description: Specify whether sticker pack downloads should be ignored when
|
||||||
|
receiving messages
|
||||||
|
in: query
|
||||||
|
name: ignore_stickers
|
||||||
|
type: string
|
||||||
- description: 'Specify the maximum number of messages to receive (default:
|
- description: 'Specify the maximum number of messages to receive (default:
|
||||||
unlimited)'
|
unlimited)'
|
||||||
in: query
|
in: query
|
||||||
|
|||||||
@ -395,6 +395,8 @@ func main() {
|
|||||||
autoReceiveScheduleReceiveTimeout := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_RECEIVE_TIMEOUT", "10")
|
autoReceiveScheduleReceiveTimeout := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_RECEIVE_TIMEOUT", "10")
|
||||||
autoReceiveScheduleIgnoreAttachments := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_IGNORE_ATTACHMENTS", "false")
|
autoReceiveScheduleIgnoreAttachments := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_IGNORE_ATTACHMENTS", "false")
|
||||||
autoReceiveScheduleIgnoreStories := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_IGNORE_STORIES", "false")
|
autoReceiveScheduleIgnoreStories := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_IGNORE_STORIES", "false")
|
||||||
|
autoReceiveScheduleIgnoreAvatars := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_IGNORE_AVATARS", "false")
|
||||||
|
autoReceiveScheduleIgnoreStickers := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_IGNORE_STICKERS", "false")
|
||||||
autoReceiveScheduleSendReadReceipts := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_SEND_READ_RECEIPTS", "false")
|
autoReceiveScheduleSendReadReceipts := utils.GetEnv("AUTO_RECEIVE_SCHEDULE_SEND_READ_RECEIPTS", "false")
|
||||||
|
|
||||||
c := cron.New()
|
c := cron.New()
|
||||||
@ -424,6 +426,8 @@ func main() {
|
|||||||
q.Add("timeout", autoReceiveScheduleReceiveTimeout)
|
q.Add("timeout", autoReceiveScheduleReceiveTimeout)
|
||||||
q.Add("ignore_attachments", autoReceiveScheduleIgnoreAttachments)
|
q.Add("ignore_attachments", autoReceiveScheduleIgnoreAttachments)
|
||||||
q.Add("ignore_stories", autoReceiveScheduleIgnoreStories)
|
q.Add("ignore_stories", autoReceiveScheduleIgnoreStories)
|
||||||
|
q.Add("ignore_avatars", autoReceiveScheduleIgnoreAvatars)
|
||||||
|
q.Add("ignore_stickers", autoReceiveScheduleIgnoreStickers)
|
||||||
q.Add("send_read_receipts", autoReceiveScheduleSendReadReceipts)
|
q.Add("send_read_receipts", autoReceiveScheduleSendReadReceipts)
|
||||||
req.URL.RawQuery = q.Encode()
|
req.URL.RawQuery = q.Encode()
|
||||||
|
|
||||||
|
|||||||
@ -42,12 +42,22 @@ func main() {
|
|||||||
|
|
||||||
ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "")
|
ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "")
|
||||||
if ignoreAttachments == "true" {
|
if ignoreAttachments == "true" {
|
||||||
args = append(args, " --ignore-attachments")
|
args = append(args, "--ignore-attachments")
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreStories := utils.GetEnv("JSON_RPC_IGNORE_STORIES", "")
|
ignoreStories := utils.GetEnv("JSON_RPC_IGNORE_STORIES", "")
|
||||||
if ignoreStories == "true" {
|
if ignoreStories == "true" {
|
||||||
args = append(args, " --ignore-stories")
|
args = append(args, "--ignore-stories")
|
||||||
|
}
|
||||||
|
|
||||||
|
ignoreAvatars := utils.GetEnv("JSON_RPC_IGNORE_AVATARS", "")
|
||||||
|
if ignoreAvatars == "true" {
|
||||||
|
args = append(args, "--ignore-avatars")
|
||||||
|
}
|
||||||
|
|
||||||
|
ignoreStickers := utils.GetEnv("JSON_RPC_IGNORE_STICKERS", "")
|
||||||
|
if ignoreStickers == "true" {
|
||||||
|
args = append(args, "--ignore-stickers")
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, []string{"--tcp", "127.0.0.1:" + strconv.FormatInt(tcpPort, 10)}...)
|
args = append(args, []string{"--tcp", "127.0.0.1:" + strconv.FormatInt(tcpPort, 10)}...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user