fixed error handling in send method

This commit is contained in:
Bernhard B
2024-03-26 17:36:30 +01:00
parent 4173a8ba6f
commit a627d3e1ab

View File

@@ -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 {