This commit is contained in:
syuilo 2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View file

@ -34,8 +34,8 @@ app.use(views(_dirname + '/views', {
extension: 'pug',
options: {
version: config.version,
config
}
config,
},
}));
// Serve favicon
@ -77,7 +77,7 @@ router.get('/assets/(.*)', async ctx => {
// Apple touch icon
router.get('/apple-touch-icon.png', async ctx => {
await send(ctx as any, '/apple-touch-icon.png', {
root: staticAssets
root: staticAssets,
});
});
@ -100,7 +100,7 @@ router.get('/twemoji/(.*)', async ctx => {
// ServiceWorker
router.get('/sw.js', async ctx => {
await send(ctx as any, `/sw.${config.version}.js`, {
root: assets
root: assets,
});
});
@ -109,7 +109,7 @@ router.get('/manifest.json', require('./manifest'));
router.get('/robots.txt', async ctx => {
await send(ctx as any, '/robots.txt', {
root: staticAssets
root: staticAssets,
});
});
@ -118,7 +118,7 @@ router.get('/robots.txt', async ctx => {
// Docs
router.get('/api-doc', async ctx => {
await send(ctx as any, '/redoc.html', {
root: staticAssets
root: staticAssets,
});
});
@ -134,7 +134,7 @@ const getFeed = async (acct: string) => {
const user = await Users.findOne({
usernameLower: username.toLowerCase(),
host,
isSuspended: false
isSuspended: false,
});
return user && await packFeed(user);
@ -183,7 +183,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
const user = await Users.findOne({
usernameLower: username.toLowerCase(),
host,
isSuspended: false
isSuspended: false,
});
if (user != null) {
@ -199,7 +199,7 @@ router.get(['/@:user', '/@:user/:sub'], async (ctx, next) => {
user, profile, me,
sub: ctx.params.sub,
instanceName: meta.name || 'Misskey',
icon: meta.iconUrl
icon: meta.iconUrl,
});
ctx.set('Cache-Control', 'public, max-age=30');
} else {
@ -213,7 +213,7 @@ router.get('/users/:user', async ctx => {
const user = await Users.findOne({
id: ctx.params.user,
host: null,
isSuspended: false
isSuspended: false,
});
if (user == null) {
@ -238,7 +238,7 @@ router.get('/notes/:note', async (ctx, next) => {
// TODO: Let locale changeable by instance setting
summary: getNoteSummary(_note),
instanceName: meta.name || 'Misskey',
icon: meta.iconUrl
icon: meta.iconUrl,
});
if (['public', 'home'].includes(note.visibility)) {
@ -258,14 +258,14 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
const { username, host } = Acct.parse(ctx.params.user);
const user = await Users.findOne({
usernameLower: username.toLowerCase(),
host
host,
});
if (user == null) return;
const page = await Pages.findOne({
name: ctx.params.page,
userId: user.id
userId: user.id,
});
if (page) {
@ -275,7 +275,7 @@ router.get('/@:user/pages/:page', async (ctx, next) => {
await ctx.render('page', {
page: _page,
profile,
instanceName: meta.name || 'Misskey'
instanceName: meta.name || 'Misskey',
});
if (['public'].includes(page.visibility)) {
@ -304,7 +304,7 @@ router.get('/clips/:clip', async (ctx, next) => {
await ctx.render('clip', {
clip: _clip,
profile,
instanceName: meta.name || 'Misskey'
instanceName: meta.name || 'Misskey',
});
ctx.set('Cache-Control', 'public, max-age=180');
@ -327,7 +327,7 @@ router.get('/gallery/:post', async (ctx, next) => {
post: _post,
profile,
instanceName: meta.name || 'Misskey',
icon: meta.iconUrl
icon: meta.iconUrl,
});
ctx.set('Cache-Control', 'public, max-age=180');
@ -349,7 +349,7 @@ router.get('/channels/:channel', async (ctx, next) => {
const meta = await fetchMeta();
await ctx.render('channel', {
channel: _channel,
instanceName: meta.name || 'Misskey'
instanceName: meta.name || 'Misskey',
});
ctx.set('Cache-Control', 'public, max-age=180');
@ -371,7 +371,7 @@ router.get('/_info_card_', async ctx => {
host: config.host,
meta: meta,
originalUsersCount: await Users.count({ host: null }),
originalNotesCount: await Notes.count({ userHost: null })
originalNotesCount: await Notes.count({ userHost: null }),
});
});
@ -411,7 +411,7 @@ router.get('(.*)', async ctx => {
title: meta.name || 'Misskey',
instanceName: meta.name || 'Misskey',
desc: meta.description,
icon: meta.iconUrl
icon: meta.iconUrl,
});
ctx.set('Cache-Control', 'public, max-age=300');
});