mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-22 14:04:28 +00:00
parent
f57512216c
commit
9c365e6f84
@ -112,6 +112,7 @@ type SendMessageV2 struct {
|
|||||||
QuoteMessage *string `json:"quote_message"`
|
QuoteMessage *string `json:"quote_message"`
|
||||||
QuoteMentions []client.MessageMention `json:"quote_mentions"`
|
QuoteMentions []client.MessageMention `json:"quote_mentions"`
|
||||||
TextMode *string `json:"text_mode" enums:"normal,styled"`
|
TextMode *string `json:"text_mode" enums:"normal,styled"`
|
||||||
|
EditTimestamp *int64 `json:"edit_timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypingIndicatorRequest struct {
|
type TypingIndicatorRequest struct {
|
||||||
@ -397,7 +398,7 @@ func (a *Api) SendV2(c *gin.Context) {
|
|||||||
|
|
||||||
timestamps, err := a.signalClient.SendV2(
|
timestamps, 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.TextMode)
|
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions, req.TextMode, req.EditTimestamp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, Error{Msg: err.Error()})
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
return
|
return
|
||||||
|
|||||||
@ -343,7 +343,8 @@ func (s *MessageMention) toString() string {
|
|||||||
|
|
||||||
func (s *SignalClient) send(number string, message string,
|
func (s *SignalClient) send(number string, message string,
|
||||||
recipients []string, base64Attachments []string, isGroup bool, sticker string, mentions []MessageMention,
|
recipients []string, base64Attachments []string, isGroup bool, sticker string, mentions []MessageMention,
|
||||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention, textMode *string) (*SendResponse, error) {
|
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention, textMode *string,
|
||||||
|
editTimestamp *int64) (*SendResponse, error) {
|
||||||
|
|
||||||
var resp SendResponse
|
var resp SendResponse
|
||||||
|
|
||||||
@ -400,6 +401,7 @@ func (s *SignalClient) send(number string, message string,
|
|||||||
QuoteMessage *string `json:"quote-message,omitempty"`
|
QuoteMessage *string `json:"quote-message,omitempty"`
|
||||||
QuoteMentions []string `json:"quote-mentions,omitempty"`
|
QuoteMentions []string `json:"quote-mentions,omitempty"`
|
||||||
TextStyles []string `json:"text-style,omitempty"`
|
TextStyles []string `json:"text-style,omitempty"`
|
||||||
|
EditTimestamp *int64 `json:"edit-timestamp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
request := Request{Message: message}
|
request := Request{Message: message}
|
||||||
@ -432,6 +434,7 @@ func (s *SignalClient) send(number string, message string,
|
|||||||
} else {
|
} else {
|
||||||
request.QuoteMentions = nil
|
request.QuoteMentions = nil
|
||||||
}
|
}
|
||||||
|
request.EditTimestamp = editTimestamp
|
||||||
|
|
||||||
if len(signalCliTextFormatStrings) > 0 {
|
if len(signalCliTextFormatStrings) > 0 {
|
||||||
request.TextStyles = signalCliTextFormatStrings
|
request.TextStyles = signalCliTextFormatStrings
|
||||||
@ -500,6 +503,11 @@ func (s *SignalClient) send(number string, message string,
|
|||||||
cmd = append(cmd, mention.toString())
|
cmd = append(cmd, mention.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if editTimestamp != nil {
|
||||||
|
cmd = append(cmd, "--edit-timestamp")
|
||||||
|
cmd = append(cmd, strconv.FormatInt(*editTimestamp, 10))
|
||||||
|
}
|
||||||
|
|
||||||
rawData, err := s.cliClient.Execute(true, cmd, message)
|
rawData, err := s.cliClient.Execute(true, cmd, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanupAttachmentEntries(attachmentEntries)
|
cleanupAttachmentEntries(attachmentEntries)
|
||||||
@ -627,7 +635,7 @@ func (s *SignalClient) VerifyRegisteredNumber(number string, token string, pin s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) SendV1(number string, message string, recipients []string, base64Attachments []string, isGroup bool) (*SendResponse, error) {
|
func (s *SignalClient) SendV1(number string, message string, recipients []string, base64Attachments []string, isGroup bool) (*SendResponse, error) {
|
||||||
timestamp, err := s.send(number, message, recipients, base64Attachments, isGroup, "", nil, nil, nil, nil, nil, nil)
|
timestamp, err := s.send(number, message, recipients, base64Attachments, isGroup, "", nil, nil, nil, nil, nil, nil, nil)
|
||||||
return timestamp, err
|
return timestamp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,7 +655,7 @@ func (s *SignalClient) getJsonRpc2Clients() []*JsonRpc2Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) SendV2(number string, message string, recps []string, base64Attachments []string, sticker string, mentions []MessageMention,
|
func (s *SignalClient) SendV2(number string, message string, recps []string, base64Attachments []string, sticker string, mentions []MessageMention,
|
||||||
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention, textMode *string) (*[]SendResponse, error) {
|
quoteTimestamp *int64, quoteAuthor *string, quoteMessage *string, quoteMentions []MessageMention, textMode *string, editTimestamp *int64) (*[]SendResponse, 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")
|
||||||
}
|
}
|
||||||
@ -677,7 +685,8 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
|||||||
|
|
||||||
timestamps := []SendResponse{}
|
timestamps := []SendResponse{}
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
timestamp, err := s.send(number, message, []string{group}, base64Attachments, true, sticker, mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions, textMode)
|
timestamp, err := s.send(number, message, []string{group}, base64Attachments, true, sticker,
|
||||||
|
mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions, textMode, editTimestamp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -685,7 +694,8 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(recipients) > 0 {
|
if len(recipients) > 0 {
|
||||||
timestamp, err := s.send(number, message, recipients, base64Attachments, false, sticker, mentions, quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions, textMode)
|
timestamp, err := s.send(number, message, recipients, base64Attachments, false, sticker, mentions,
|
||||||
|
quoteTimestamp, quoteAuthor, quoteMessage, quoteMentions, textMode, editTimestamp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2040,6 +2040,9 @@ var doc = `{
|
|||||||
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
|
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"edit_timestamp": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"mentions": {
|
"mentions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@ -2024,6 +2024,9 @@
|
|||||||
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
|
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"edit_timestamp": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"mentions": {
|
"mentions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@ -138,6 +138,8 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
|
edit_timestamp:
|
||||||
|
type: integer
|
||||||
mentions:
|
mentions:
|
||||||
items:
|
items:
|
||||||
$ref: '#/definitions/client.MessageMention'
|
$ref: '#/definitions/client.MessageMention'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user