mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-20 16:14:29 +01:00
fixed error handling in send method
This commit is contained in:
@@ -452,14 +452,6 @@ func (s *SignalClient) send(number string, message string,
|
|||||||
rawData, err := jsonRpc2Client.getRaw("send", &number, request)
|
rawData, err := jsonRpc2Client.getRaw("send", &number, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanupAttachmentEntries(attachmentEntries)
|
cleanupAttachmentEntries(attachmentEntries)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(rawData), &resp)
|
|
||||||
if err != nil {
|
|
||||||
if strings.Contains(err.Error(), signalCliV2GroupError) {
|
|
||||||
return nil, errors.New("Cannot send message to group - please first update your profile.")
|
|
||||||
}
|
|
||||||
|
|
||||||
switch errorType := err.(type) {
|
switch errorType := err.(type) {
|
||||||
case *RateLimitErrorType:
|
case *RateLimitErrorType:
|
||||||
@@ -471,6 +463,16 @@ func (s *SignalClient) send(number string, message string,
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(rawData), &resp)
|
||||||
|
if err != nil {
|
||||||
|
cleanupAttachmentEntries(attachmentEntries)
|
||||||
|
|
||||||
|
if strings.Contains(err.Error(), signalCliV2GroupError) {
|
||||||
|
return nil, errors.New("Cannot send message to group - please first update your profile.")
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd := []string{"--config", s.signalCliConfig, "-a", number, "send", "--message-from-stdin"}
|
cmd := []string{"--config", s.signalCliConfig, "-a", number, "send", "--message-from-stdin"}
|
||||||
if !isGroup {
|
if !isGroup {
|
||||||
|
|||||||
Reference in New Issue
Block a user