diff --git a/src/api/api.go b/src/api/api.go index 4d8307c..e252821 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -112,6 +112,7 @@ type SendMessageV2 struct { QuoteMessage *string `json:"quote_message"` QuoteMentions []client.MessageMention `json:"quote_mentions"` TextMode *string `json:"text_mode" enums:"normal,styled"` + EditTimestamp *int64 `json:"edit_timestamp"` } type TypingIndicatorRequest struct { @@ -397,7 +398,7 @@ func (a *Api) SendV2(c *gin.Context) { timestamps, err := a.signalClient.SendV2( 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 { c.JSON(400, Error{Msg: err.Error()}) return diff --git a/src/client/client.go b/src/client/client.go index 21a1dd6..ba0e51f 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -343,7 +343,8 @@ func (s *MessageMention) toString() string { func (s *SignalClient) send(number string, message string, 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 @@ -400,6 +401,7 @@ func (s *SignalClient) send(number string, message string, QuoteMessage *string `json:"quote-message,omitempty"` QuoteMentions []string `json:"quote-mentions,omitempty"` TextStyles []string `json:"text-style,omitempty"` + EditTimestamp *int64 `json:"edit-timestamp,omitempty"` } request := Request{Message: message} @@ -432,6 +434,7 @@ func (s *SignalClient) send(number string, message string, } else { request.QuoteMentions = nil } + request.EditTimestamp = editTimestamp if len(signalCliTextFormatStrings) > 0 { request.TextStyles = signalCliTextFormatStrings @@ -500,6 +503,11 @@ func (s *SignalClient) send(number string, message string, 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) if err != nil { 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) { - 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 } @@ -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, - 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 { 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{} 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 { return nil, err } @@ -685,7 +694,8 @@ func (s *SignalClient) SendV2(number string, message string, recps []string, bas } 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 { return nil, err } diff --git a/src/docs/docs.go b/src/docs/docs.go index 35b7467..ad2528c 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -2040,6 +2040,9 @@ var doc = `{ "data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e" ] }, + "edit_timestamp": { + "type": "integer" + }, "mentions": { "type": "array", "items": { diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 8088c7b..116c8b6 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -2024,6 +2024,9 @@ "data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e" ] }, + "edit_timestamp": { + "type": "integer" + }, "mentions": { "type": "array", "items": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index 1bf07d5..ba8543d 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -138,6 +138,8 @@ definitions: items: type: string type: array + edit_timestamp: + type: integer mentions: items: $ref: '#/definitions/client.MessageMention'