From 80e1ce09df73f1ee6c6b836f18cca652b11d233c Mon Sep 17 00:00:00 2001 From: Karar Al-Remahy Date: Tue, 25 May 2021 15:18:14 +0200 Subject: [PATCH] fix: don't check for success oEmbed status (#152) --- CHANGELOG.md | 2 +- internal/resolvers/oembed/README.md | 6 +++--- internal/resolvers/oembed/load.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d32d84..a3d734ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Added support for customizable oEmbed resolving for websites with the `providers.json` file. See [`data/oembed/providers.json`](data/oembed/providers.json). Three new environment variables can be set. See [`internal/resolvers/oembed/README.md`](internal/resolvers/oembed/README.md) (#139) +- Added support for customizable oEmbed resolving for websites with the `providers.json` file. See [`data/oembed/providers.json`](data/oembed/providers.json). Three new environment variables can be set. See [`internal/resolvers/oembed/README.md`](internal/resolvers/oembed/README.md) (#139, #152) - Breaking: Environment variable `CHATTERINO_API_CACHE_TWITCH_CLIENT_ID` was renamed to `CHATTERINO_API_TWITCH_CLIENT_ID`. (#144) - Dev, Breaking: Replaced `dankeroni/gotwitch` with `nicklaw5/helix`. This change requires you to add new environment variable: `CHATTERINO_API_TWITCH_CLIENT_SECRET` - it's a client secret generated for your Twitch application. diff --git a/internal/resolvers/oembed/README.md b/internal/resolvers/oembed/README.md index 969e30bb..072ecfca 100644 --- a/internal/resolvers/oembed/README.md +++ b/internal/resolvers/oembed/README.md @@ -1,7 +1,7 @@ # oEmbed -The oEmbed resolver requires a `resolvers.json` to be loadable from the application. +The oEmbed resolver requires a `providers.json` to be loadable from the application. -The `CHATTERINO_API_OEMBED_PROVIDERS_PATH` environment variable can be set to change where the file is loaded from, and if no environment variable is set it tries to load the file from `./resolvers.json`. +The `CHATTERINO_API_OEMBED_PROVIDERS_PATH` environment variable can be set to change where the file is loaded from, and if no environment variable is set it tries to load the file from `./providers.json`. -If the Facebook and Instagram resolvers are part of your `resolvers.json` file, you can specify the `CHATTERINO_API_OEMBED_FACEBOOK_APP_ID` and `CHATTERINO_API_OEMBED_FACEBOOK_APP_SECRET` environment variables to grant Authorization for those requests, giving you rich data for Facebook and Instagram posts. +If Facebook and Instagram oEmbed providers are in your `providers.json` file, you can specify the `CHATTERINO_API_OEMBED_FACEBOOK_APP_ID` and `CHATTERINO_API_OEMBED_FACEBOOK_APP_SECRET` environment variables to grant Authorization for those requests, giving you rich data for Facebook and Instagram posts. diff --git a/internal/resolvers/oembed/load.go b/internal/resolvers/oembed/load.go index d5e56bd2..da51e21c 100644 --- a/internal/resolvers/oembed/load.go +++ b/internal/resolvers/oembed/load.go @@ -40,7 +40,7 @@ func load(requestedURL string, r *http.Request) (interface{}, time.Duration, err }, cache.NoSpecialDur, nil } - if data.Status < http.StatusOK || data.Status > http.StatusMultipleChoices { + if data.Status > http.StatusOK { log.Printf("[oEmbed] Skipping url %s because status code is %d\n", requestedURL, data.Status) return &resolver.Response{ Status: data.Status,