Hide private data in pug when private mode is enabled
This commit is contained in:
parent
a69557f193
commit
3f14e23431
|
@ -218,6 +218,10 @@ router.get('/api.json', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const getFeed = async (acct: string) => {
|
const getFeed = async (acct: string) => {
|
||||||
|
const meta = await fetchMeta();
|
||||||
|
if (meta.privateMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { username, host } = Acct.parse(acct);
|
const { username, host } = Acct.parse(acct);
|
||||||
const user = await Users.findOneBy({
|
const user = await Users.findOneBy({
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
|
@ -290,6 +294,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
} else {
|
} else {
|
||||||
|
@ -333,6 +338,7 @@ router.get('/notes/:note', async (ctx, next) => {
|
||||||
summary: getNoteSummary(_note),
|
summary: getNoteSummary(_note),
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -370,6 +376,7 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (['public'].includes(page.visibility)) {
|
if (['public'].includes(page.visibility)) {
|
||||||
|
@ -400,6 +407,7 @@ router.get('/clips/:clip', async (ctx, next) => {
|
||||||
profile,
|
profile,
|
||||||
avatarUrl: await Users.getAvatarUrl(await Users.findOneByOrFail({ id: clip.userId })),
|
avatarUrl: await Users.getAvatarUrl(await Users.findOneByOrFail({ id: clip.userId })),
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
|
privateMode: meta.privateMode,
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
});
|
});
|
||||||
|
@ -427,6 +435,7 @@ router.get('/gallery/:post', async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -451,6 +460,7 @@ router.get('/channels/:channel', async (ctx, next) => {
|
||||||
instanceName: meta.name || 'Misskey',
|
instanceName: meta.name || 'Misskey',
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
|
@ -464,6 +474,10 @@ router.get('/channels/:channel', async (ctx, next) => {
|
||||||
|
|
||||||
router.get('/_info_card_', async ctx => {
|
router.get('/_info_card_', async ctx => {
|
||||||
const meta = await fetchMeta(true);
|
const meta = await fetchMeta(true);
|
||||||
|
if (meta.privateMode) {
|
||||||
|
ctx.status = 403;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.remove('X-Frame-Options');
|
ctx.remove('X-Frame-Options');
|
||||||
|
|
||||||
|
@ -511,6 +525,7 @@ router.get('(.*)', async ctx => {
|
||||||
desc: meta.description,
|
desc: meta.description,
|
||||||
icon: meta.iconUrl,
|
icon: meta.iconUrl,
|
||||||
themeColor: meta.themeColor,
|
themeColor: meta.themeColor,
|
||||||
|
privateMode: meta.privateMode,
|
||||||
});
|
});
|
||||||
ctx.set('Cache-Control', 'public, max-age=15');
|
ctx.set('Cache-Control', 'public, max-age=15');
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,6 +51,8 @@ html
|
||||||
meta(name='description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
meta(name='description' content= desc || '✨🌎✨ A interplanetary communication platform ✨🚀✨')
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
if privateMode
|
||||||
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
block og
|
block og
|
||||||
meta(property='og:title' content= title || 'Misskey')
|
meta(property='og:title' content= title || 'Misskey')
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
extends ./base
|
extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const title = channel.name;
|
- const title = privateMode ? '非公開インスタンス' : channel.name;
|
||||||
- const url = `${config.url}/channels/${channel.id}`;
|
- const url = `${config.url}/channels/${channel.id}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
|
unless privateMode
|
||||||
meta(name='description' content=channel.description)
|
meta(name='description' content=channel.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
|
unless privateMode
|
||||||
meta(property='og:type' content='article')
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:description' content= channel.description)
|
meta(property='og:description' content= channel.description)
|
||||||
|
|
|
@ -2,16 +2,18 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = clip.user;
|
- const user = clip.user;
|
||||||
- const title = clip.name;
|
- const title = privateMode ? '非公開インスタンス' : clip.name;
|
||||||
- const url = `${config.url}/clips/${clip.id}`;
|
- const url = `${config.url}/clips/${clip.id}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
|
unless privateMode
|
||||||
meta(name='description' content= clip.description)
|
meta(name='description' content= clip.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
|
unless privateMode
|
||||||
meta(property='og:type' content='article')
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:description' content= clip.description)
|
meta(property='og:description' content= clip.description)
|
||||||
|
@ -19,6 +21,7 @@ block og
|
||||||
meta(property='og:image' content= avatarUrl)
|
meta(property='og:image' content= avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
unless privateMode
|
||||||
if profile.noCrawle
|
if profile.noCrawle
|
||||||
meta(name='robots' content='noindex')
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,18 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = post.user;
|
- const user = post.user;
|
||||||
- const title = post.title;
|
- const title = privateMode ? '非公開インスタンス' : post.title;
|
||||||
- const url = `${config.url}/gallery/${post.id}`;
|
- const url = `${config.url}/gallery/${post.id}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
|
unless privateMode
|
||||||
meta(name='description' content= post.description)
|
meta(name='description' content= post.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
|
unless privateMode
|
||||||
meta(property='og:type' content='article')
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:description' content= post.description)
|
meta(property='og:description' content= post.description)
|
||||||
|
@ -19,6 +21,7 @@ block og
|
||||||
meta(property='og:image' content= post.files[0].thumbnailUrl)
|
meta(property='og:image' content= post.files[0].thumbnailUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
unless privateMode
|
||||||
if user.host || profile.noCrawle
|
if user.host || profile.noCrawle
|
||||||
meta(name='robots' content='noindex')
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = note.user;
|
- const user = note.user;
|
||||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
- const title = privateMode ? '非公開インスタンス' : (user.name ? `${user.name} (@${user.username})` : `@${user.username}`);
|
||||||
- const url = `${config.url}/notes/${note.id}`;
|
- const url = `${config.url}/notes/${note.id}`;
|
||||||
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
||||||
|
|
||||||
|
@ -10,9 +10,11 @@ block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
|
unless privateMode
|
||||||
meta(name='description' content= summary)
|
meta(name='description' content= summary)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
|
unless privateMode
|
||||||
meta(property='og:type' content='article')
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:description' content= summary)
|
meta(property='og:description' content= summary)
|
||||||
|
@ -20,6 +22,7 @@ block og
|
||||||
meta(property='og:image' content= avatarUrl)
|
meta(property='og:image' content= avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
unless privateMode
|
||||||
if user.host || isRenote || profile.noCrawle
|
if user.host || isRenote || profile.noCrawle
|
||||||
meta(name='robots' content='noindex')
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,18 @@ extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const user = page.user;
|
- const user = page.user;
|
||||||
- const title = page.title;
|
- const title = privateMode ? '非公開インスタンス' : page.title;
|
||||||
- const url = `${config.url}/@${user.username}/${page.name}`;
|
- const url = `${config.url}/@${user.username}/${page.name}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
|
unless privateMode
|
||||||
meta(name='description' content= page.summary)
|
meta(name='description' content= page.summary)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
|
unless privateMode
|
||||||
meta(property='og:type' content='article')
|
meta(property='og:type' content='article')
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:description' content= page.summary)
|
meta(property='og:description' content= page.summary)
|
||||||
|
@ -19,6 +21,7 @@ block og
|
||||||
meta(property='og:image' content= page.eyeCatchingImage ? page.eyeCatchingImage.thumbnailUrl : avatarUrl)
|
meta(property='og:image' content= page.eyeCatchingImage ? page.eyeCatchingImage.thumbnailUrl : avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
unless privateMode
|
||||||
if profile.noCrawle
|
if profile.noCrawle
|
||||||
meta(name='robots' content='noindex')
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
extends ./base
|
extends ./base
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
- const title = privateMode ? '非公開インスタンス' : (user.name ? `${user.name} (@${user.username})` : `@${user.username}`);
|
||||||
- const url = `${config.url}/@${(user.host ? `${user.username}@${user.host}` : user.username)}`;
|
- const url = `${config.url}/@${(user.host ? `${user.username}@${user.host}` : user.username)}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
||||||
block desc
|
block desc
|
||||||
|
unless privateMode
|
||||||
meta(name='description' content= profile.description)
|
meta(name='description' content= profile.description)
|
||||||
|
|
||||||
block og
|
block og
|
||||||
|
unless privateMode
|
||||||
meta(property='og:type' content='blog')
|
meta(property='og:type' content='blog')
|
||||||
meta(property='og:title' content= title)
|
meta(property='og:title' content= title)
|
||||||
meta(property='og:description' content= profile.description)
|
meta(property='og:description' content= profile.description)
|
||||||
|
@ -18,6 +20,7 @@ block og
|
||||||
meta(property='og:image' content= avatarUrl)
|
meta(property='og:image' content= avatarUrl)
|
||||||
|
|
||||||
block meta
|
block meta
|
||||||
|
unless privateMode
|
||||||
if user.host || profile.noCrawle
|
if user.host || profile.noCrawle
|
||||||
meta(name='robots' content='noindex')
|
meta(name='robots' content='noindex')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue