fix: presentUnfurl
This commit is contained in:
14
server/presenters/unfurls/unfurl.ts
Normal file
14
server/presenters/unfurls/unfurl.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Unfurl } from "@shared/types";
|
||||
|
||||
function presentUnfurl(data: any): Unfurl {
|
||||
return {
|
||||
url: data.url,
|
||||
type: data.type,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
thumbnailUrl: data.thumbnail_url,
|
||||
meta: data.meta,
|
||||
};
|
||||
}
|
||||
|
||||
export default presentUnfurl;
|
||||
@@ -8,6 +8,7 @@ import validate from "@server/middlewares/validate";
|
||||
import { Document, User } from "@server/models";
|
||||
import { authorize } from "@server/policies";
|
||||
import { presentDocument, presentMention } from "@server/presenters/unfurls";
|
||||
import presentUnfurl from "@server/presenters/unfurls/unfurl";
|
||||
import { APIContext } from "@server/types";
|
||||
import { RateLimiterStrategy } from "@server/utils/RateLimiter";
|
||||
import { Iframely } from "@server/utils/unfurl";
|
||||
@@ -62,7 +63,7 @@ router.post(
|
||||
}
|
||||
|
||||
const data = await Iframely.unfurl(url);
|
||||
ctx.body = data;
|
||||
ctx.body = presentUnfurl(data);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -214,13 +214,15 @@ export enum UnfurlType {
|
||||
Document = "document",
|
||||
}
|
||||
|
||||
export type Unfurl<T = unknown> = {
|
||||
export type OEmbedType = "photo" | "video" | "rich";
|
||||
|
||||
export type Unfurl<T = OEmbedType> = {
|
||||
url?: string;
|
||||
type: T;
|
||||
title: string;
|
||||
description: string;
|
||||
thumbnailUrl?: string | null;
|
||||
meta: Record<string, string>;
|
||||
meta?: Record<string, string>;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
Reference in New Issue
Block a user