Fix static-fe Twitter metadata / URL previews #700

Merged
floatingghost merged 2 commits from Oneric/akkoma:staticfe-metadata into develop 2024-02-24 13:42:56 +00:00
Member

help, diff and commit message length are inversely proportional again


This partly reverts 1d884fd914 while fixing both the issue it addressed and the issue it caused.

The above commit successfully fixed OpenGraph metadata tags which until then always showed the user bio instead of post content by handing the activities AP ID as url to the Metadata builder instead of passing the internal ID as activity_id.
However, in doing so the commit instead inflicted this very problem onto Twitter metadata tags which ironically are used by akkoma-fe.

This is because while the OpenGraph builder wants an URL as url, the Twitter builder needs the internal ID to build the URL to the embedded player for videos and has no URL property.

Thanks to twpol for tracking down this root cause in #644.

Now, once identified the problem is simple, but this simplicity invites multiple possible solutions to bikeshed about.

  1. Just pass both properties to the builder and let them pick

  2. Drop the url parameter from the OpenGraph builder and instead
    a) build static-fe URL of the post from the ID (like Twitter)
    b) use the passed-in object’s AP ID as an URL

Approach 2a has the disadvantage of hardcoding the expected URL outside
the router, which will be problematic should it ever change.
Approach 2b is conceptually similar to how the builder works atm.
However, the og:url is supposed to be a permanent ID, by changing from the ID of the Create activity to the ID of the object we, afaiu, technically violate OpenGraph specs. (Though its real-world consequence may very well be near non-existent.)

This leaves just approach 1, which this commit implements. Albeit it too is not without nits to pick, as it leaves the metadata builders with an inconsistent interface.

Additionally, this will resolve the subotpimal Discord previews for content-less image posts reported in #664.
Discord already prefers OpenGraph metadata, so it’s mostly unaffected. However, it appears when encountering an explicitly empty OpenGraph description and a non-empty Twitter description, it replaces just the empty field with its Twitter counterpart, resulting in the user’s bio slipping into the preview.
Secondly, regardless of any OpenGraph tags, Discord uses twitter:card to decide how prominently images should be, but due to the bug the card type was stuck as "summary", forcing images to always remain small.

Root cause identified by: twpol

Fixes: #644
Fixes: #664

help, diff and commit message length are inversely proportional again ----- This partly reverts 1d884fd9143dc165d745bf1b5e86bcc65332d6b9 while fixing both the issue it addressed and the issue it caused. The above commit successfully fixed OpenGraph metadata tags which until then always showed the user bio instead of post content by handing the activities AP ID as url to the Metadata builder _instead_ of passing the internal ID as activity_id. However, in doing so the commit instead inflicted this very problem onto Twitter metadata tags which ironically are used by akkoma-fe. This is because while the OpenGraph builder wants an URL as url, the Twitter builder needs the internal ID to build the URL to the embedded player for videos and has no URL property. Thanks to twpol for tracking down this root cause in #644. Now, once identified the problem is simple, but this simplicity invites multiple possible solutions to bikeshed about. 1. Just pass both properties to the builder and let them pick 2. Drop the url parameter from the OpenGraph builder and instead a) build static-fe URL of the post from the ID (like Twitter) b) use the passed-in object’s AP ID as an URL Approach 2a has the disadvantage of hardcoding the expected URL outside the router, which will be problematic should it ever change. Approach 2b is conceptually similar to how the builder works atm. However, the og:url is supposed to be a _permanent_ ID, by changing from the ID of the Create activity to the ID of the object we, afaiu, technically violate OpenGraph specs. (Though its real-world consequence may very well be near non-existent.) This leaves just approach 1, which this commit implements. Albeit it too is not without nits to pick, as it leaves the metadata builders with an inconsistent interface. Additionally, this will resolve the subotpimal Discord previews for content-less image posts reported in #664. Discord already prefers OpenGraph metadata, so it’s mostly unaffected. However, it appears when encountering an explicitly empty OpenGraph description and a non-empty Twitter description, it replaces just the empty field with its Twitter counterpart, resulting in the user’s bio slipping into the preview. Secondly, regardless of any OpenGraph tags, Discord uses twitter:card to decide how prominently images should be, but due to the bug the card type was stuck as "summary", forcing images to always remain small. Root cause identified by: twpol Fixes: https://akkoma.dev/AkkomaGang/akkoma/issues/644 Fixes: https://akkoma.dev/AkkomaGang/akkoma/issues/664
Oneric changed title from Fix Twitter metadata / URL previews to Fix static-fe Twitter metadata / URL previews 2024-02-20 02:35:53 +00:00
Oneric force-pushed staticfe-metadata from 2459dc5b4f to 37e2a35b86 2024-02-20 03:21:43 +00:00 Compare

any chance you could add a quick test to this to show what we expect to be generated?

any chance you could add a quick test to this to show what we expect to be generated?
Oneric force-pushed staticfe-metadata from 8da54ae206 to ea2dbd9ef5 2024-02-21 02:02:42 +00:00 Compare
Author
Member

tests added

tests added
Oneric force-pushed staticfe-metadata from ea2dbd9ef5 to c08f49d88e 2024-02-21 02:09:00 +00:00 Compare

coolio, thanks~

coolio, thanks~
floatingghost merged commit 7d61fb0906 into develop 2024-02-24 13:42:56 +00:00
floatingghost deleted branch staticfe-metadata 2024-02-24 13:42:56 +00:00
Sign in to join this conversation.
No description provided.