mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
catch errors while building opengraph metadata to allow _some_ metadata to make it out still
This commit is contained in:
parent
18e0c990e4
commit
9a96582bfc
1 changed files with 19 additions and 14 deletions
|
|
@ -37,20 +37,25 @@ async function buildTemplateOpts(params: PathParams, url: string): Promise<OpenG
|
|||
h: 48,
|
||||
},
|
||||
};
|
||||
|
||||
if (params.acct && !params.statusId) {
|
||||
const profile = await getProfileInfo(params.acct);
|
||||
res.type = 'profile';
|
||||
res.title = `View @${await getHandle(params.acct)}'s profile on Ditto`;
|
||||
res.description = profile.about;
|
||||
if (profile.picture) {
|
||||
res.image = { url: profile.picture, h: 150, w: 150 };
|
||||
try {
|
||||
if (params.acct && !params.statusId) {
|
||||
const profile = await getProfileInfo(params.acct);
|
||||
res.type = 'profile';
|
||||
res.title = `View @${await getHandle(params.acct, profile.name)}'s profile on Ditto`;
|
||||
res.description = profile.about;
|
||||
if (profile.picture) {
|
||||
res.image = { url: profile.picture, h: 150, w: 150 };
|
||||
}
|
||||
} else if (params.statusId) {
|
||||
const { description, image, title } = await getStatusInfo(params.statusId);
|
||||
res.description = description;
|
||||
res.image = image;
|
||||
res.title = title;
|
||||
}
|
||||
} else if (params.statusId) {
|
||||
const { description, image, title } = await getStatusInfo(params.statusId);
|
||||
res.description = description;
|
||||
res.image = image;
|
||||
res.title = title;
|
||||
} catch (e) {
|
||||
console.debug('Error getting OpenGraph metadata information:');
|
||||
console.debug(e);
|
||||
console.trace();
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
@ -66,7 +71,7 @@ export const frontendController: AppMiddleware = async (c, next) => {
|
|||
const meta = metadataView(await buildTemplateOpts(params, Conf.local(c.req.path)));
|
||||
return c.html(content.replace(META_PLACEHOLDER, meta));
|
||||
} catch (e) {
|
||||
console.debug(e);
|
||||
console.log(e);
|
||||
return c.html(content);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue