refactor: migrate to typeorm 3.0 (#8443)

* wip

* wip

* wip

* Update following.ts

* wip

* wip

* wip

* Update resolve-user.ts

* maxQueryExecutionTime

* wip

* wip
This commit is contained in:
syuilo
2022-03-26 15:34:00 +09:00
committed by GitHub
parent 41c87074e6
commit 1c67c26bd8
325 changed files with 1314 additions and 1494 deletions

View File

@@ -15,7 +15,7 @@ import { inbox as processInbox } from '@/queue/index.js';
import { isSelfHost } from '@/misc/convert-host.js';
import { Notes, Users, Emojis, NoteReactions } from '@/models/index.js';
import { ILocalUser, User } from '@/models/entities/user.js';
import { In } from 'typeorm';
import { In, IsNull } from 'typeorm';
import { renderLike } from '@/remote/activitypub/renderer/like.js';
import { getUserKeypair } from '@/misc/keypair-store.js';
@@ -65,7 +65,7 @@ router.post('/users/:user/inbox', json(), inbox);
router.get('/notes/:note', async (ctx, next) => {
if (!isActivityPubReq(ctx)) return await next();
const note = await Notes.findOne({
const note = await Notes.findOneBy({
id: ctx.params.note,
visibility: In(['public' as const, 'home' as const]),
localOnly: false,
@@ -93,9 +93,9 @@ router.get('/notes/:note', async (ctx, next) => {
// note activity
router.get('/notes/:note/activity', async ctx => {
const note = await Notes.findOne({
const note = await Notes.findOneBy({
id: ctx.params.note,
userHost: null,
userHost: IsNull(),
visibility: In(['public' as const, 'home' as const]),
localOnly: false,
});
@@ -126,9 +126,9 @@ router.get('/users/:user/collections/featured', Featured);
router.get('/users/:user/publickey', async ctx => {
const userId = ctx.params.user;
const user = await Users.findOne({
const user = await Users.findOneBy({
id: userId,
host: null,
host: IsNull(),
});
if (user == null) {
@@ -164,9 +164,9 @@ router.get('/users/:user', async (ctx, next) => {
const userId = ctx.params.user;
const user = await Users.findOne({
const user = await Users.findOneBy({
id: userId,
host: null,
host: IsNull(),
isSuspended: false,
});
@@ -176,9 +176,9 @@ router.get('/users/:user', async (ctx, next) => {
router.get('/@:user', async (ctx, next) => {
if (!isActivityPubReq(ctx)) return await next();
const user = await Users.findOne({
const user = await Users.findOneBy({
usernameLower: ctx.params.user.toLowerCase(),
host: null,
host: IsNull(),
isSuspended: false,
});
@@ -188,8 +188,8 @@ router.get('/@:user', async (ctx, next) => {
// emoji
router.get('/emojis/:emoji', async ctx => {
const emoji = await Emojis.findOne({
host: null,
const emoji = await Emojis.findOneBy({
host: IsNull(),
name: ctx.params.emoji,
});
@@ -205,14 +205,14 @@ router.get('/emojis/:emoji', async ctx => {
// like
router.get('/likes/:like', async ctx => {
const reaction = await NoteReactions.findOne(ctx.params.like);
const reaction = await NoteReactions.findOneBy({ id: ctx.params.like });
if (reaction == null) {
ctx.status = 404;
return;
}
const note = await Notes.findOne(reaction.noteId);
const note = await Notes.findOneBy({ id: reaction.noteId });
if (note == null) {
ctx.status = 404;