A matrix media proxy as cloudflare worker.
HOSTNAME: the hostname, for exampleexample.orgSERVERNAME: the servername, for exampleexample.org
Example in TypeScript, as seen in mxcId.ts:
function toBase64Url(value: string): string {
const bytes = new TextEncoder().encode(value);
let binary = '';
for (const byte of bytes) {
binary += String.fromCodePoint(byte);
}
return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replaceAll(/=+$/g, '');
}
function toMatrixID(fname: string, prefix: string): string {
const base64 = toBase64Url(fname);
return prefix + base64;
}You can test it against the /_soliditas/adressconvert?remoteType=[remoteType]&remoteId=[remoteID] endpoint.
You need to generate a matrix id, using the algorithm as shown above.
Example:
- The giphy id is
yXPquATCb8kGk, this has been translated using thetoMatrixIDfunction, see above, togiphy_XPquATCb8kGk. - mxc:
mxc://example.org/giphy_XPquATCb8kGk - will return a redirect to
https://i.giphy.com/yXPquATCb8kGk.webp
You need to generate a matrix id, using the algorithm as shown above.
Example:
To-Do
You need to generate a matrix id, using the algorithm as shown above.
Example:
- The path on the klipy cdn is
ffd4ac143e6335ac68951b787d3c1902/e8/3a/5LM0jRpL.gif - mxc:
mxc://example.org/klipy_ZmZkNGFjMTQzZTYzMzVhYzY4OTUxYjc4N2QzYzE5MDIvZTgvM2EvNUxNMGpScEwuZ2lm - will return a redirect to
https://static.klipy.com/ii/ffd4ac143e6335ac68951b787d3c1902/e8/3a/5LM0jRpL.gif
GET /_soliditas/preview_url?url=[url] answers in the shape of the Matrix /preview_url endpoint. Missing og: tags are filled from twitter: tags, <title>, <meta name="description"> and oEmbed. Twitter/X links are read from the FxTwitter API, Reddit and TikTok titles from their oEmbed endpoints, Tumblr posts without an image get the fxtumblr render, and Misskey-family notes show their images from the ActivityPub object unless marked sensitive, instead of the author's avatar.
og:image is returned as mxc://[servername]/og_[base64url of the image url]. When a post has more than one image, com.sable.images lists up to ten of them as { url, width, height }, and og:image stays the single image other clients show (the FxTwitter mosaic for tweets).
This project is licensed under Apache 2.0, see LICENSE.