mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-09-20 06:09:28 +00:00
added voice_note parameter to send endpoint
This commit is contained in:
parent
1fface6074
commit
93b366cad6
@ -142,6 +142,7 @@ type SendMessageV2 struct {
|
|||||||
NotifySelf *bool `json:"notify_self,omitempty"`
|
NotifySelf *bool `json:"notify_self,omitempty"`
|
||||||
LinkPreview *ds.LinkPreviewType `json:"link_preview,omitempty"`
|
LinkPreview *ds.LinkPreviewType `json:"link_preview,omitempty"`
|
||||||
ViewOnce *bool `json:"view_once,omitempty"`
|
ViewOnce *bool `json:"view_once,omitempty"`
|
||||||
|
VoiceNote *bool `json:"voice_note,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypingIndicatorRequest struct {
|
type TypingIndicatorRequest struct {
|
||||||
@ -546,10 +547,15 @@ func (a *Api) SendV2(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.VoiceNote != nil && *req.VoiceNote && (len(req.Base64Attachments) == 0) {
|
||||||
|
c.JSON(400, Error{Msg: "'voice_note' can only be set for audio attachments!"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
data, err := a.signalClient.SendV2(
|
data, err := a.signalClient.SendV2(
|
||||||
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
|
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
|
||||||
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions,
|
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions,
|
||||||
textMode, req.EditTimestamp, req.NotifySelf, req.LinkPreview, req.ViewOnce)
|
textMode, req.EditTimestamp, req.NotifySelf, req.LinkPreview, req.ViewOnce, req.VoiceNote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case *client.RateLimitErrorType:
|
case *client.RateLimitErrorType:
|
||||||
|
|||||||
@ -550,6 +550,7 @@ func (s *SignalClient) send(signalCliSendRequest ds.SignalCliSendRequest) (*ds.S
|
|||||||
PreviewImage *string `json:"preview-image,omitempty"`
|
PreviewImage *string `json:"preview-image,omitempty"`
|
||||||
PreviewDescription *string `json:"preview-description,omitempty"`
|
PreviewDescription *string `json:"preview-description,omitempty"`
|
||||||
ViewOnce bool `json:"view-once,omitempty"`
|
ViewOnce bool `json:"view-once,omitempty"`
|
||||||
|
VoiceNote bool `json:"voice-note,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
request := Request{Message: signalCliSendRequest.Message}
|
request := Request{Message: signalCliSendRequest.Message}
|
||||||
@ -573,6 +574,10 @@ func (s *SignalClient) send(signalCliSendRequest ds.SignalCliSendRequest) (*ds.S
|
|||||||
request.ViewOnce = true
|
request.ViewOnce = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if signalCliSendRequest.VoiceNote != nil && *signalCliSendRequest.VoiceNote {
|
||||||
|
request.VoiceNote = true
|
||||||
|
}
|
||||||
|
|
||||||
request.Sticker = signalCliSendRequest.Sticker
|
request.Sticker = signalCliSendRequest.Sticker
|
||||||
if signalCliSendRequest.Mentions != nil {
|
if signalCliSendRequest.Mentions != nil {
|
||||||
request.Mentions = make([]string, len(signalCliSendRequest.Mentions))
|
request.Mentions = make([]string, len(signalCliSendRequest.Mentions))
|
||||||
@ -709,6 +714,10 @@ func (s *SignalClient) send(signalCliSendRequest ds.SignalCliSendRequest) (*ds.S
|
|||||||
cmd = append(cmd, "--view-once")
|
cmd = append(cmd, "--view-once")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if signalCliSendRequest.VoiceNote != nil && *signalCliSendRequest.VoiceNote {
|
||||||
|
cmd = append(cmd, "--voice-note")
|
||||||
|
}
|
||||||
|
|
||||||
rawData, err = s.cliClient.Execute(true, cmd, signalCliSendRequest.Message)
|
rawData, err = s.cliClient.Execute(true, cmd, signalCliSendRequest.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanupAttachmentEntries(attachmentEntries, linkPreviewAttachmentEntry)
|
cleanupAttachmentEntries(attachmentEntries, linkPreviewAttachmentEntry)
|
||||||
@ -946,7 +955,7 @@ func (s *SignalClient) getJsonRpc2Clients() []*JsonRpc2Client {
|
|||||||
|
|
||||||
func (s *SignalClient) SendV2(number string, message string, recps []string, base64Attachments []string, sticker string, mentions []ds.MessageMention,
|
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,
|
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []ds.MessageMention, textMode *string, editTimestamp *int64, notifySelf *bool,
|
||||||
linkPreview *ds.LinkPreviewType, viewOnce *bool) (*[]ds.SendMessageResponse, error) {
|
linkPreview *ds.LinkPreviewType, viewOnce *bool, voiceNote *bool) (*[]ds.SendMessageResponse, error) {
|
||||||
if len(recps) == 0 {
|
if len(recps) == 0 {
|
||||||
return nil, errors.New("Please provide at least one recipient")
|
return nil, errors.New("Please provide at least one recipient")
|
||||||
}
|
}
|
||||||
@ -997,7 +1006,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
|||||||
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: []string{group}, Base64Attachments: base64Attachments,
|
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: []string{group}, Base64Attachments: base64Attachments,
|
||||||
RecipientType: ds.Group, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
RecipientType: ds.Group, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
||||||
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
||||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce}
|
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce, VoiceNote: voiceNote}
|
||||||
resp, err := s.send(signalCliSendRequest)
|
resp, err := s.send(signalCliSendRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1009,7 +1018,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
|||||||
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: numbers, Base64Attachments: base64Attachments,
|
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: numbers, Base64Attachments: base64Attachments,
|
||||||
RecipientType: ds.Number, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
RecipientType: ds.Number, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
||||||
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
||||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce}
|
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce, VoiceNote: voiceNote}
|
||||||
resp, err := s.send(signalCliSendRequest)
|
resp, err := s.send(signalCliSendRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1021,7 +1030,7 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
|||||||
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: usernames, Base64Attachments: base64Attachments,
|
signalCliSendRequest := ds.SignalCliSendRequest{Number: number, Message: message, Recipients: usernames, Base64Attachments: base64Attachments,
|
||||||
RecipientType: ds.Username, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
RecipientType: ds.Username, Sticker: sticker, Mentions: mentions, QuoteTimestamp: quoteTimestamp,
|
||||||
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
QuoteAuthor: quoteAuthor, QuoteMessage: quoteMessage, QuoteMentions: quoteMentions,
|
||||||
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce}
|
TextMode: textMode, EditTimestamp: editTimestamp, NotifySelf: notifySelf, LinkPreview: linkPreview, ViewOnce: viewOnce, VoiceNote: voiceNote}
|
||||||
resp, err := s.send(signalCliSendRequest)
|
resp, err := s.send(signalCliSendRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -51,6 +51,7 @@ type SignalCliSendRequest struct {
|
|||||||
NotifySelf *bool
|
NotifySelf *bool
|
||||||
LinkPreview *LinkPreviewType
|
LinkPreview *LinkPreviewType
|
||||||
ViewOnce *bool
|
ViewOnce *bool
|
||||||
|
VoiceNote *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupPermissions struct {
|
type GroupPermissions struct {
|
||||||
|
|||||||
@ -468,6 +468,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"view_once": {
|
"view_once": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"voice_note": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@ -463,6 +463,9 @@
|
|||||||
},
|
},
|
||||||
"view_once": {
|
"view_once": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"voice_note": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user