From 031ad331e495853ef2bed774f7ecbeb9ff63c55a Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 22 Mar 2024 21:28:14 +0100 Subject: [PATCH] [eventsub] Fix: Do not retry subscription on collision resolves #TWITCH-BOT-7 Signed-off-by: Knut Ahlers --- pkg/twitch/eventsub.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/twitch/eventsub.go b/pkg/twitch/eventsub.go index fe7bd11..690bf92 100644 --- a/pkg/twitch/eventsub.go +++ b/pkg/twitch/eventsub.go @@ -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") }