fixed bug in send method

* with signal-cli 0.13.0 the default behavior changed
  and message to oneself did not trigger a notification anymore.

  As this is a behavioral change and we try to avoid any behavioral
  changes in the REST API, the previous behavior was reinstated again
  by explicitly adding "--notify-self".

see #511
This commit is contained in:
Bernhard B 2024-04-04 19:58:03 +02:00
parent 8c9b797026
commit dfdcfa3725

View File

@ -410,6 +410,7 @@ func (s *SignalClient) send(number string, message string,
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"` EditTimestamp *int64 `json:"edit-timestamp,omitempty"`
NotifySelf bool `json:"notify-self,omitempty"`
} }
request := Request{Message: message} request := Request{Message: message}
@ -422,6 +423,8 @@ func (s *SignalClient) send(number string, message string,
request.Attachments = append(request.Attachments, attachmentEntry.toDataForSignal()) request.Attachments = append(request.Attachments, attachmentEntry.toDataForSignal())
} }
request.NotifySelf = true
request.Sticker = sticker request.Sticker = sticker
if mentions != nil { if mentions != nil {
request.Mentions = make([]string, len(mentions)) request.Mentions = make([]string, len(mentions))
@ -518,6 +521,8 @@ func (s *SignalClient) send(number string, message string,
cmd = append(cmd, strconv.FormatInt(*editTimestamp, 10)) cmd = append(cmd, strconv.FormatInt(*editTimestamp, 10))
} }
cmd = append(cmd, "--notify-self")
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)