[eventsub] Fix: Do not retry subscription on collision
resolves #TWITCH-BOT-7 Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
abe839df3a
commit
031ad331e4
1 changed files with 9 additions and 0 deletions
|
@ -298,6 +298,15 @@ func (c *Client) createEventSubSubscription(ctx context.Context, auth AuthType,
|
||||||
OKStatus: http.StatusAccepted,
|
OKStatus: http.StatusAccepted,
|
||||||
Out: &resp,
|
Out: &resp,
|
||||||
URL: "https://api.twitch.tv/helix/eventsub/subscriptions",
|
URL: "https://api.twitch.tv/helix/eventsub/subscriptions",
|
||||||
|
ValidateFunc: func(opts ClientRequestOpts, resp *http.Response) error {
|
||||||
|
if resp.StatusCode == http.StatusConflict {
|
||||||
|
// This is fine: We needed that subscription, it exists
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to default handling
|
||||||
|
return ValidateStatus(opts, resp)
|
||||||
|
},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, errors.Wrap(err, "executing request")
|
return nil, errors.Wrap(err, "executing request")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue