[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:
Knut Ahlers 2024-03-22 21:28:14 +01:00
parent abe839df3a
commit 031ad331e4
Signed by: luzifer
SSH key fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E

View file

@ -298,6 +298,15 @@ func (c *Client) createEventSubSubscription(ctx context.Context, auth AuthType,
OKStatus: http.StatusAccepted,
Out: &resp,
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 {
return nil, errors.Wrap(err, "executing request")
}