Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 7545ef1e1901a5bfd33aaa55a2320e003ea39126 Co-authored-by: MisterGuy420 <255743668+MisterGuy420@users.noreply.github.com> Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Reviewed-by: @gumadeiras
21 lines
589 B
TypeScript
21 lines
589 B
TypeScript
import { loadWebMedia } from "../web/media.js";
|
|
import { saveMediaBuffer } from "./store.js";
|
|
|
|
export async function resolveOutboundAttachmentFromUrl(
|
|
mediaUrl: string,
|
|
maxBytes: number,
|
|
options?: { localRoots?: readonly string[] },
|
|
): Promise<{ path: string; contentType?: string }> {
|
|
const media = await loadWebMedia(mediaUrl, {
|
|
maxBytes,
|
|
localRoots: options?.localRoots,
|
|
});
|
|
const saved = await saveMediaBuffer(
|
|
media.buffer,
|
|
media.contentType ?? undefined,
|
|
"outbound",
|
|
maxBytes,
|
|
);
|
|
return { path: saved.path, contentType: saved.contentType };
|
|
}
|