mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-04-21 09:00:16 +00:00
parent
407db38356
commit
4102331404
@ -127,6 +127,7 @@ type SendMessageV2 struct {
|
||||
EditTimestamp *int64 `json:"edit_timestamp"`
|
||||
NotifySelf *bool `json:"notify_self"`
|
||||
LinkPreview *ds.LinkPreviewType `json:"link_preview"`
|
||||
ViewOnce *bool `json:"view_once"`
|
||||
}
|
||||
|
||||
type TypingIndicatorRequest struct {
|
||||
@ -448,10 +449,15 @@ func (a *Api) SendV2(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if req.ViewOnce != nil && *req.ViewOnce && (len(req.Base64Attachments) == 0) {
|
||||
c.JSON(400, Error{Msg: "'view_once' can only be set for image attachments!"})
|
||||
return
|
||||
}
|
||||
|
||||
data, err := a.signalClient.SendV2(
|
||||
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
|
||||
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions,
|
||||
textMode, req.EditTimestamp, req.NotifySelf, req.LinkPreview)
|
||||
textMode, req.EditTimestamp, req.NotifySelf, req.LinkPreview, req.ViewOnce)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case *client.RateLimitErrorType:
|
||||
|
||||
@ -513,6 +513,7 @@ func (s *SignalClient) send(signalCliSendRequest ds.SignalCliSendRequest) (*Send
|
||||
PreviewUrl *string `json:"preview-url,omitempty"`
|
||||
PreviewTitle *string `json:"preview-title,omitempty"`
|
||||
PreviewImage *string `json:"preview-image,omitempty"`
|
||||
ViewOnce bool `json:"view-once,omitempty"`
|
||||
}
|
||||
|
||||
request := Request{Message: signalCliSendRequest.Message}
|
||||
@ -532,6 +533,10 @@ func (s *SignalClient) send(signalCliSendRequest ds.SignalCliSendRequest) (*Send
|
||||
request.NotifySelf = true
|
||||
}
|
||||
|
||||
if signalCliSendRequest.ViewOnce != nil && *signalCliSendRequest.ViewOnce {
|
||||
request.ViewOnce = true
|
||||
}
|
||||
|
||||
request.Sticker = signalCliSendRequest.Sticker
|
||||
if signalCliSendRequest.Mentions != nil {
|
||||
request.Mentions = make([]string, len(signalCliSendRequest.Mentions))
|
||||
@ -670,6 +675,10 @@ func (s *SignalClient) send(signalCliSendRequest ds.SignalCliSendRequest) (*Send
|
||||
cmd = append(cmd, "--notify-self")
|
||||
}
|
||||
|
||||
if signalCliSendRequest.ViewOnce != nil && *signalCliSendRequest.ViewOnce {
|
||||
cmd = append(cmd, "--view-once")
|
||||
}
|
||||
|
||||
rawData, err := s.cliClient.Execute(true, cmd, signalCliSendRequest.Message)
|
||||
if err != nil {
|
||||
cleanupAttachmentEntries(attachmentEntries, linkPreviewAttachmentEntry)
|
||||
@ -826,7 +835,7 @@ func (s *SignalClient) getJsonRpc2Clients() []*JsonRpc2Client {
|
||||
|
||||
func (s *SignalClient) SendV2(number string, message string, recps []string, base64Attachments []string, sticker string, mentions []ds.MessageMention,
|
||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []ds.MessageMention, textMode *string, editTimestamp *int64, notifySelf *bool,
|
||||
linkPreview *ds.LinkPreviewType) (*[]SendResponse, error) {
|
||||
linkPreview *ds.LinkPreviewType, viewOnce *bool) (*[]SendResponse, error) {
|
||||
if len(recps) == 0 {
|
||||
return nil, errors.New("Please provide at least one recipient")
|
||||
}
|
||||
@ -877,7 +886,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
||||
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: []string{group}, Base64Attachments: base64Attachments,
|
||||
RecipientType: ds.Group, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
||||
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview}
|
||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce}
|
||||
timestamp, err := s.send(signalCliSendRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -889,7 +898,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
||||
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: numbers, Base64Attachments: base64Attachments,
|
||||
RecipientType: ds.Number, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
||||
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview}
|
||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce}
|
||||
timestamp, err := s.send(signalCliSendRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -901,7 +910,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
||||
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: usernames, Base64Attachments: base64Attachments,
|
||||
RecipientType: ds.Username, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
||||
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview}
|
||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce}
|
||||
timestamp, err := s.send(signalCliSendRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -50,4 +50,5 @@ type SignalCliSendRequest struct {
|
||||
EditTimestamp *int64
|
||||
NotifySelf *bool
|
||||
LinkPreview *LinkPreviewType
|
||||
ViewOnce *bool
|
||||
}
|
||||
|
||||
@ -2519,6 +2519,9 @@ const docTemplate = `{
|
||||
"normal",
|
||||
"styled"
|
||||
]
|
||||
},
|
||||
"view_once": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -2625,6 +2628,14 @@ const docTemplate = `{
|
||||
"expiration_time": {
|
||||
"type": "integer"
|
||||
},
|
||||
"group_link": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"disabled",
|
||||
"enabled",
|
||||
"enabled-with-approval"
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
|
||||
@ -2516,6 +2516,9 @@
|
||||
"normal",
|
||||
"styled"
|
||||
]
|
||||
},
|
||||
"view_once": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -2622,6 +2625,14 @@
|
||||
"expiration_time": {
|
||||
"type": "integer"
|
||||
},
|
||||
"group_link": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"disabled",
|
||||
"enabled",
|
||||
"enabled-with-approval"
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
|
||||
@ -207,6 +207,8 @@ definitions:
|
||||
- normal
|
||||
- styled
|
||||
type: string
|
||||
view_once:
|
||||
type: boolean
|
||||
type: object
|
||||
api.SetPinRequest:
|
||||
properties:
|
||||
@ -275,6 +277,12 @@ definitions:
|
||||
type: string
|
||||
expiration_time:
|
||||
type: integer
|
||||
group_link:
|
||||
enum:
|
||||
- disabled
|
||||
- enabled
|
||||
- enabled-with-approval
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user