umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.36k stars 2.64k forks source link

Twitter embeds broken now that it is "x.com" #16645

Closed Eaglef90 closed 2 days ago

Eaglef90 commented 6 days ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.4.0

Bug summary

If you want to use the RTE's built in Embed fuction to embed a post on twitter you can't use the x.com address as that give a "not supported" error on the retrieve function.

Specifics

With twitter.com now being x.com if you use the new domain to try and embed a tweet in an RTE you will get an error message saying "not supported". If you update the URL to use twitter.com then it works just fine.

Steps to reproduce

Copy a tweet URL from the x.com domain. Got to any RTE property and click the Embed icon Paste the x.com URL and hit retrieve to get an error

Expected result / actual result

The function should work with the x.com domain just like it does for twitter.com

github-actions[bot] commented 6 days ago

Hi there @Eaglef90!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

elit0451 commented 5 days ago

Hi @Eaglef90 👋

Thanks for reaching out! I tried following the guide from X's help center - https://help.x.com/en/using-x/how-to-embed-a-post and that worked for me. Was it any different for you? 🙂

Eaglef90 commented 5 days ago

I did look into that but it generates html code which means now my content editors have to get into editing the rte source. The emebd metgod is just a button press, url psats, button press done.

As far as I know the embed method ia nit depreicated and if the intent is to support twitter embedding it would be nice to update it to accept the x.com doman

elit0451 commented 4 days ago

I get it now. It is fixed in https://github.com/umbraco/Umbraco-CMS/pull/16650

Until we release this update, you can implement a custom EmbedProvider, like:

public class X : OEmbedProviderBase
{
    public X(IJsonSerializer jsonSerializer)
        : base(jsonSerializer)
    {
    }

    public override string ApiEndpoint => "http://publish.twitter.com/oembed";

    public override string[] UrlSchemeRegex => new[] { @"(https?:\/\/(www\.)?)(twitter|x)\.com\/.*\/status\/.*" };

    public override Dictionary<string, string> RequestParams => new();

    public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
    {
        var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
        OEmbedResponse? oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);

        return oembed?.GetHtml();
    }
}
public class RegisterEmbedProvidersComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
        => builder.EmbedProviders().Append<X>();
}
elit0451 commented 2 days ago

Fixed in https://github.com/umbraco/Umbraco-CMS/pull/16650