From d1694ee88cbf1b256b1ba34a745d552cb991017a Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Tue, 23 Jul 2024 20:42:29 +0200 Subject: [PATCH] add account to SendMessageError json response * when a rate limiting error is returned, also include the account information (this is quite useful for multi account setups). see #566 --- src/api/api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/api.go b/src/api/api.go index 1d98cff..fb1a5f6 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -134,6 +134,7 @@ type Error struct { type SendMessageError struct { Msg string `json:"error"` ChallengeTokens []string `json:"challenge_tokens,omitempty"` + Account string `json:"account"` } type CreateGroupResponse struct { @@ -423,7 +424,7 @@ func (a *Api) SendV2(c *gin.Context) { 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(429, SendMessageError{Msg: extendedError.Error(), ChallengeTokens: rateLimitError.ChallengeTokens}) + c.JSON(429, SendMessageError{Msg: extendedError.Error(), ChallengeTokens: rateLimitError.ChallengeTokens, Account: req.Number}) return } else { c.JSON(400, Error{Msg: err.Error()})