Preview arbitrary urls within a document (#5598)

This commit is contained in:
Apoorv Mishra
2023-07-30 05:21:49 +05:30
committed by GitHub
parent 67691477a9
commit ddc883bfcd
8 changed files with 83 additions and 38 deletions

View File

@@ -11,7 +11,7 @@ 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";
import resolvers from "@server/utils/unfurl";
import * as T from "./schema";
const router = new Router();
@@ -62,12 +62,14 @@ router.post(
return;
}
const data = await Iframely.unfurl(url);
if (data.error) {
ctx.response.status = 204;
return;
if (resolvers.Iframely) {
const data = await resolvers.Iframely.unfurl(url);
return data.error
? (ctx.response.status = 204)
: (ctx.body = presentUnfurl(data));
}
ctx.body = presentUnfurl(data);
return (ctx.response.status = 204);
}
);