feat(api): 🔒 Make all media be proxied through an internal proxy

This commit is contained in:
Jesse Wierzbinski 2024-05-04 19:13:23 -10:00
parent 9547cd097a
commit ead34b818f
No known key found for this signature in database
8 changed files with 54 additions and 18 deletions

View file

@ -1,3 +1,4 @@
import { proxyUrl } from "@response";
import type { Config } from "config-manager";
import type { InferSelectModel } from "drizzle-orm";
import type * as Lysand from "lysand-types";
@ -25,9 +26,9 @@ export const attachmentToAPI = (
return {
id: attachment.id,
type: type as "image" | "video" | "audio" | "unknown",
url: attachment.url,
remote_url: attachment.remoteUrl,
preview_url: attachment.thumbnailUrl || attachment.url,
url: proxyUrl(attachment.url) ?? "",
remote_url: proxyUrl(attachment.remoteUrl),
preview_url: proxyUrl(attachment.thumbnailUrl || attachment.url),
text_url: null,
meta: {
width: attachment.width || undefined,

View file

@ -1,3 +1,4 @@
import { proxyUrl } from "@response";
import { type InferSelectModel, and, eq } from "drizzle-orm";
import type * as Lysand from "lysand-types";
import { db } from "~drizzle/db";
@ -93,8 +94,8 @@ export const fetchEmoji = async (
export const emojiToAPI = (emoji: EmojiWithInstance): APIEmoji => {
return {
shortcode: emoji.shortcode,
static_url: emoji.url, // TODO: Add static version
url: emoji.url,
static_url: proxyUrl(emoji.url) ?? "", // TODO: Add static version
url: proxyUrl(emoji.url) ?? "",
visible_in_picker: emoji.visibleInPicker,
category: undefined,
};