mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
fixed bug in /v2/send error parsing
This commit is contained in:
@@ -410,8 +410,18 @@ func (a *Api) SendV2(c *gin.Context) {
|
||||
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
|
||||
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions, req.TextMode, req.EditTimestamp)
|
||||
if err != nil {
|
||||
if data != nil {
|
||||
c.JSON(400, SendMessageError{Msg: err.Error(), ChallengeTokens: (*data)[0].ChallengeTokens})
|
||||
switch err.(type) {
|
||||
case *client.RateLimitErrorType:
|
||||
if rateLimitError, ok := err.(*client.RateLimitErrorType); ok {
|
||||
extendedError := errors.New(err.Error() + ". Use the attached challenge tokens to lift the rate limit restrictions via the '/v1/accounts/{number}/rate-limit-challenge' endpoint.")
|
||||
c.JSON(400, SendMessageError{Msg: extendedError.Error(), ChallengeTokens: rateLimitError.ChallengeTokens})
|
||||
return
|
||||
} else {
|
||||
c.JSON(400, Error{Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
default:
|
||||
c.JSON(400, Error{Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(400, Error{Msg: err.Error()})
|
||||
|
||||
@@ -162,7 +162,6 @@ type SignalCliIdentityEntry struct {
|
||||
|
||||
type SendResponse struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
ChallengeTokens []string `json:"challenge_tokens"`
|
||||
}
|
||||
|
||||
type About struct {
|
||||
@@ -452,15 +451,6 @@ func (s *SignalClient) send(number string, message string,
|
||||
rawData, err := jsonRpc2Client.getRaw("send", &number, request)
|
||||
if err != nil {
|
||||
cleanupAttachmentEntries(attachmentEntries)
|
||||
|
||||
switch errorType := err.(type) {
|
||||
case *RateLimitErrorType:
|
||||
rateLimitError := errors.New(err.Error() + ". Use the attached challenge tokens to lift the rate limit restrictions via the '/v1/accounts/{number}/rate-limit-challenge' endpoint.")
|
||||
resp.ChallengeTokens = errorType.ChallengeTokens
|
||||
return &resp, rateLimitError
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user