Merge branch 'notification-read-api' into swn

This commit is contained in:
tamaina 2021-12-11 00:57:22 +09:00
commit b4954fe7c2
635 changed files with 4867 additions and 4789 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

@ -35,8 +35,8 @@ app.use(views(_dirname + '/views', {
extension: 'pug',
options: {
version: config.version,
config
}
config,
},
}));
// Serve favicon
@ -78,7 +78,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,
});
});
@ -101,12 +101,12 @@ router.get('/twemoji/(.*)', async ctx => {
// ServiceWorker
router.get('/sw.js', async ctx => {
await send(ctx as any, `/sw.js`, {
root: swAssets
root: swAssets,
});
});
router.get(`/sw-lib.${config.version}.js`, async ctx => {
await send(ctx as any, `/sw-lib.js`, {
root: swAssets
root: swAssets,
});
});
@ -115,7 +115,7 @@ router.get('/manifest.json', require('./manifest'));
router.get('/robots.txt', async ctx => {
await send(ctx as any, '/robots.txt', {
root: staticAssets
root: staticAssets,
});
});
@ -124,7 +124,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,
});
});
@ -140,7 +140,7 @@ const getFeed = async (acct: string) => {
const user = await Users.findOne({
usernameLower: username.toLowerCase(),
host,
isSuspended: false
isSuspended: false,
});
return user && await packFeed(user);
@ -189,7 +189,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) {
@ -205,7 +205,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 {
@ -219,7 +219,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) {
@ -244,7 +244,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)) {
@ -264,14 +264,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) {
@ -281,7 +281,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)) {
@ -310,7 +310,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');
@ -333,7 +333,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');
@ -355,7 +355,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');
@ -377,7 +377,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 }),
});
});
@ -417,7 +417,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;