ShaneIsrael / fireshare

Self host your media and share with unique links
GNU General Public License v3.0
642 stars 39 forks source link

[BUG] possibly incorrect open graph metadata implementation #240

Closed eliasbenb closed 6 months ago

eliasbenb commented 6 months ago

Describe the bug I noticed that open graph metadata seems to be broken when shared through any of Meta's services (Facebook, WhatsApp, Instagram) but it works fine when shared through Discord and Twitter (possibly others too).

At first, I thought it was because Meta blocks OG data from untrustworthy domains, but after using the Meta sharing debugger, I don't think that's the case. Even the sharing debugger reports that no OG tags are provided when I put in a fireshare video URL.

I checked the Open Graph protocol reference page and it looks like there might be a discrepancy in the way you wrote the OG tags.

As an example, this is what is outputted by fireshare

<meta property="og:video" value="/_content/video/39658c033f450c274e558258fd9c6ce2.mp4" data-react-helmet="true">

And here is an example from the Open Graph protocol reference page

<meta property="og:video" content="https://example.com/bond/trailer.swf" />

The difference is that while the open graph protocol reference page uses a content key, fireshare is using a value key. Not to say using value is incorrect, but it might be incorrect for Meta.

I haven't investigated further, so I'm not sure if this is true or if something else is causing the issue.

ShaneIsrael commented 6 months ago

This is a good catch and could very well be the reason it's not working correctly on those sites. I'll update it to use content rather than value and hopefully that resolves the problem. I don't have a way to test against Meta's sites since I don't have any accounts with them. But as long as it still works in Discord I'll assume that it's at the very least, not any worse.

ShaneIsrael commented 6 months ago

@eliasbenb I've tested that it still works correctly in Discord. Please let me know if this update resolved the issues for you. Should be available in v1.2.18 in a few minutes.

eliasbenb commented 6 months ago

@ShaneIsrael just tested and I can confirm it's working. Everything except the og:video tag shows up. Since the thumbnail works but not the video, I assume it's an issue on Meta's side and not fireshare. According to this post Meta has been restricting videos being shown on link previews. Thank you for making the changes, this project is awesome!

eliasbenb commented 6 months ago

Ignore my last message. I just found this piece of documentation from Meta. According to them, you must:

Use a secure URL for both the og:video:url and og:video:secure_url tags to make your video eligible to play in-line in Feed. Note that your video is not guaranteed to play in-line based on a variety of factors.

I'm not sure if you're able to figure out whether the host is HTTPS or not, but if you can then it should be possible to get video previews working. Edit: on second thought, it shouldn't matter if you know the host is HTTPS or not. Adding it either way shouldn't hurt.

ShaneIsrael commented 6 months ago

For that to work, I'll need to define another environment variable for DOMAIN which can then be injected into the metadata template.

ShaneIsrael commented 6 months ago

Okay I've updated it. (v1.2.19) You'll need to pass a new DOMAIN environment variable in your docker config set to your instance domain without http / https.

So for the fireshare demo site. The value would be DOMAIN=v.fireshare.net in the docker-compose.yml file.