Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new release #145

Open
raae opened this issue Jan 4, 2021 · 8 comments
Open

Create a new release #145

raae opened this issue Jan 4, 2021 · 8 comments
Assignees
Labels

Comments

@raae
Copy link
Member

raae commented Jan 4, 2021

No description provided.

@raae raae self-assigned this Jan 4, 2021
@YoranBrondsema
Copy link

Yes please! Anything I can do to get the Instagram fix into a new release?

@raae
Copy link
Member Author

raae commented Feb 3, 2021

A new release does not fix Instagram, one has to add an access_token to the Setting to do so. See the updated readme.

I should of course also get on with making a new release as well. I might reach out to you to test the new release before releasing.

@raae raae added the devops label Feb 3, 2021
@raae
Copy link
Member Author

raae commented Feb 3, 2021

I see that the order of Instagram endpoints have been changed in the provider list this plugin rely on, meaning the deprecated endpoint is now favoured. I do not understand why it is in there at all, I will make a PR against @iamcal/oembed.

So even with adding an access_token it will be broken right now.

I am thinking more and more that I might need to keep my own vetted list, or get more involved with that repo as well.

@YoranBrondsema
Copy link

YoranBrondsema commented Feb 3, 2021

I agree, it's confusing that in https://github.com/iamcal/oembed/blob/1db773d2665db51101776744f04a0a15b0086bdc/providers/instagram.yml a same URL can match multiple endpoints.

It does seem like the schemes in @iamcal/oembed are sorted by order of preference though. So the first match should be the "correct" one. If that's the assumption, then it would make sense to rewrite https://github.com/raae/gatsby-remark-oembed/blob/master/gatsby-remark-oembed/utils/getProviderEndpointForLinkUrl.js as:

const getProviderEndpointForLinkUrl = (linkUrl, providers) => {
  for (const provider of providers || []) {
    for (const endpoint of provider.endpoints || []) {
      const isInstagram = provider.provider_name === "Instagram";
      const hasAccessToken = provider.params && provider.params.access_token;

      for (let schema of endpoint.schemes || []) {
        schema = schema.replace("*", ".*");
        const regExp = new RegExp(schema);
        const isMatchingSchema = regExp.test(linkUrl);

        if (isMatchingSchema && isInstagram && !hasAccessToken) {
          throw new Error(
            "Instagram require you to configure an access_token. For more information, visit https://developers.facebook.com/docs/instagram/oembed/."
          );
        } else if (isMatchingSchema) {
          return {
            url: endpoint.url,
            params: {
              url: linkUrl,
              ...provider.params
            }
          };
        }
      }
    }
  }

  return {};
};

so return early as soon as a match is found. Would that make sense?

@raae
Copy link
Member Author

raae commented Feb 3, 2021

The deprecated endpoint has been removed (iamcal/oembed#515), it should be reflected in the provider list within an hour and Instagram embed should work again if you provide an access_token.

@raae
Copy link
Member Author

raae commented Feb 3, 2021

@YoranBrondsema I would like to do a complete refactor of the code you reference as this was my first ever node project and I have learned a lot since then. Therefore I do not think we need to update this now as all providers should have only one match for the foreseeable future.

However when I get around to diagramming the refactor and roadmap for this plugin I would love to have you contribute.

@YoranBrondsema
Copy link

@raae Sounds good! Thanks for following up on the issue on https://github.com/iamcal/oembed.

@raae
Copy link
Member Author

raae commented Apr 11, 2022

Working on it, help test the next version - see #159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants