mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
added debug logging
This commit is contained in:
@@ -410,20 +410,27 @@ func (a *Api) SendV2(c *gin.Context) {
|
|||||||
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
|
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
|
||||||
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions, req.TextMode, req.EditTimestamp)
|
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions, req.TextMode, req.EditTimestamp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug("API: got an error")
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case *client.RateLimitErrorType:
|
case *client.RateLimitErrorType:
|
||||||
|
log.Debug("Received a rate limit error")
|
||||||
if rateLimitError, ok := err.(*client.RateLimitErrorType); ok {
|
if rateLimitError, ok := err.(*client.RateLimitErrorType); ok {
|
||||||
|
log.Debug("Converted rate limit error to error type")
|
||||||
|
log.Debug("num of challenge tokens = ", len(rateLimitError.ChallengeTokens))
|
||||||
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.")
|
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})
|
c.JSON(400, SendMessageError{Msg: extendedError.Error(), ChallengeTokens: rateLimitError.ChallengeTokens})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
log.Debug("Couldn't convert error to rate limit error")
|
||||||
c.JSON(400, Error{Msg: err.Error()})
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
log.Debug("Default errror")
|
||||||
c.JSON(400, Error{Msg: err.Error()})
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.Debug("shouldn't end up here")
|
||||||
c.JSON(400, Error{Msg: err.Error()})
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ func (r *JsonRpc2Client) getRaw(command string, account *string, args interface{
|
|||||||
if resp.Err.Code != 0 {
|
if resp.Err.Code != 0 {
|
||||||
log.Debug("json-rpc command error code: ", resp.Err.Code)
|
log.Debug("json-rpc command error code: ", resp.Err.Code)
|
||||||
if resp.Err.Code == -5 {
|
if resp.Err.Code == -5 {
|
||||||
|
log.Debug("json-rpc-client: Rate Limit Error received")
|
||||||
var rateLimitMessage RateLimitMessage
|
var rateLimitMessage RateLimitMessage
|
||||||
err = json.Unmarshal(resp.Err.Data, &rateLimitMessage)
|
err = json.Unmarshal(resp.Err.Data, &rateLimitMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -157,6 +158,7 @@ func (r *JsonRpc2Client) getRaw(command string, account *string, args interface{
|
|||||||
challengeTokens := []string{}
|
challengeTokens := []string{}
|
||||||
for _, rateLimitResult := range rateLimitMessage.Response.Results {
|
for _, rateLimitResult := range rateLimitMessage.Response.Results {
|
||||||
challengeTokens = append(challengeTokens, rateLimitResult.Token)
|
challengeTokens = append(challengeTokens, rateLimitResult.Token)
|
||||||
|
log.Debug("json-rpc-client: Received Token: ", rateLimitResult.Token)
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", &RateLimitErrorType{
|
return "", &RateLimitErrorType{
|
||||||
|
|||||||
Reference in New Issue
Block a user