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

@@ -7,7 +7,7 @@ import { In } from 'typeorm';
export default async function(user: User) {
const author = {
link: `${config.url}/@${user.username}`,
name: user.name || user.username
name: user.name || user.username,
};
const profile = await UserProfiles.findOneOrFail(user.id);
@@ -16,10 +16,10 @@ export default async function(user: User) {
where: {
userId: user.id,
renoteId: null,
visibility: In(['public', 'home'])
visibility: In(['public', 'home']),
},
order: { createdAt: -1 },
take: 20
take: 20,
});
const feed = new Feed({
@@ -35,12 +35,12 @@ export default async function(user: User) {
atom: `${author.link}.atom`,
},
author,
copyright: user.name || user.username
copyright: user.name || user.username,
});
for (const note of notes) {
const files = note.fileIds.length > 0 ? await DriveFiles.find({
id: In(note.fileIds)
id: In(note.fileIds),
}) : [];
const file = files.find(file => file.type.startsWith('image/'));
@@ -50,7 +50,7 @@ export default async function(user: User) {
date: note.createdAt,
description: note.cw || undefined,
content: note.text || undefined,
image: file ? DriveFiles.getPublicUrl(file) || undefined : undefined
image: file ? DriveFiles.getPublicUrl(file) || undefined : undefined,
});
}

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');
});

View File

@@ -18,10 +18,10 @@ module.exports = async (ctx: Koa.Context) => {
try {
const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({
url: ctx.query.url,
lang: ctx.query.lang || 'ja-JP'
lang: ctx.query.lang || 'ja-JP',
})}`) : await summaly(ctx.query.url, {
followRedirects: false,
lang: ctx.query.lang || 'ja-JP'
lang: ctx.query.lang || 'ja-JP',
});
logger.succ(`Got preview of ${ctx.query.url}: ${summary.title}`);
@@ -46,7 +46,7 @@ function wrap(url?: string): string | null {
? url.match(/^https?:\/\//)
? `${config.url}/proxy/preview.jpg?${query({
url,
preview: '1'
preview: '1',
})}`
: url
: null;