Merge branch 'notification-read-api' into swn

This commit is contained in:
tamaina 2022-03-04 15:54:03 +09:00
commit 30915d587a
912 changed files with 6686 additions and 4904 deletions

View file

@ -1,7 +1,7 @@
import { Feed } from 'feed';
import config from '@/config/index';
import { User } from '@/models/entities/user';
import { Notes, DriveFiles, UserProfiles } from '@/models/index';
import config from '@/config/index.js';
import { User } from '@/models/entities/user.js';
import { Notes, DriveFiles, UserProfiles } from '@/models/index.js';
import { In } from 'typeorm';
export default async function(user: User) {

View file

@ -2,24 +2,26 @@
* Web Client Server
*/
import { dirname } from 'path';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import ms from 'ms';
import * as Koa from 'koa';
import * as Router from '@koa/router';
import * as send from 'koa-send';
import * as favicon from 'koa-favicon';
import * as views from 'koa-views';
import Koa from 'koa';
import Router from '@koa/router';
import send from 'koa-send';
import favicon from 'koa-favicon';
import views from 'koa-views';
import packFeed from './feed';
import { fetchMeta } from '@/misc/fetch-meta';
import { genOpenapiSpec } from '../api/openapi/gen-spec';
import config from '@/config/index';
import { Users, Notes, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '@/models/index';
import * as Acct from 'misskey-js/built/acct';
import { getNoteSummary } from '@/misc/get-note-summary';
import packFeed from './feed.js';
import { fetchMeta } from '@/misc/fetch-meta.js';
import { genOpenapiSpec } from '../api/openapi/gen-spec.js';
import config from '@/config/index.js';
import { Users, Notes, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '@/models/index.js';
import * as Acct from '@/misc/acct.js';
import { getNoteSummary } from '@/misc/get-note-summary.js';
import { urlPreviewHandler } from './url-preview.js';
import { manifestHandler } from './manifest.js';
//const _filename = fileURLToPath(import.meta.url);
const _filename = __filename;
const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const staticAssets = `${_dirname}/../../../assets/`;
@ -106,7 +108,7 @@ router.get(`/sw.${config.version}.js`, async ctx => {
});
// Manifest
router.get('/manifest.json', require('./manifest'));
router.get('/manifest.json', manifestHandler);
router.get('/robots.txt', async ctx => {
await send(ctx as any, '/robots.txt', {
@ -124,7 +126,7 @@ router.get('/api-doc', async ctx => {
});
// URL preview endpoint
router.get('/url', require('./url-preview'));
router.get('/url', urlPreviewHandler);
router.get('/api.json', async ctx => {
ctx.body = genOpenapiSpec();
@ -427,4 +429,4 @@ router.get('(.*)', async ctx => {
// Register router
app.use(router.routes());
module.exports = app;
export default app;

View file

@ -1,8 +1,8 @@
import * as Koa from 'koa';
import * as manifest from './manifest.json';
import { fetchMeta } from '@/misc/fetch-meta';
import Koa from 'koa';
import manifest from './manifest.json' assert { type: 'json' };
import { fetchMeta } from '@/misc/fetch-meta.js';
module.exports = async (ctx: Koa.Context) => {
export const manifestHandler = async (ctx: Koa.Context) => {
const json = JSON.parse(JSON.stringify(manifest));
const instance = await fetchMeta(true);

View file

@ -1,14 +1,14 @@
import * as Koa from 'koa';
import Koa from 'koa';
import summaly from 'summaly';
import { fetchMeta } from '@/misc/fetch-meta';
import Logger from '@/services/logger';
import config from '@/config/index';
import { query } from '@/prelude/url';
import { getJson } from '@/misc/fetch';
import { fetchMeta } from '@/misc/fetch-meta.js';
import Logger from '@/services/logger.js';
import config from '@/config/index.js';
import { query } from '@/prelude/url.js';
import { getJson } from '@/misc/fetch.js';
const logger = new Logger('url-preview');
module.exports = async (ctx: Koa.Context) => {
export const urlPreviewHandler = async (ctx: Koa.Context) => {
const url = ctx.query.url;
if (typeof url !== 'string') {
ctx.status = 400;
@ -31,7 +31,7 @@ module.exports = async (ctx: Koa.Context) => {
const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({
url: url,
lang: lang ?? 'ja-JP',
})}`) : await summaly(url, {
})}`) : await summaly.default(url, {
followRedirects: false,
lang: lang ?? 'ja-JP',
});