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

@@ -5,13 +5,14 @@ import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-colle
import { setResponseType } from '../activitypub.js';
import renderNote from '@/remote/activitypub/renderer/note.js';
import { Users, Notes, UserNotePinings } from '@/models/index.js';
import { IsNull } from 'typeorm';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
const user = await Users.findOne({
const user = await Users.findOneBy({
id: userId,
host: null,
host: IsNull(),
});
if (user == null) {
@@ -25,7 +26,7 @@ export default async (ctx: Router.RouterContext) => {
});
const pinnedNotes = await Promise.all(pinings.map(pining =>
Notes.findOneOrFail(pining.noteId)));
Notes.findOneByOrFail({ id: pining.noteId })));
const renderedNotes = await Promise.all(pinnedNotes.map(note => renderNote(note)));

View File

@@ -9,7 +9,7 @@ import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-c
import renderFollowUser from '@/remote/activitypub/renderer/follow-user.js';
import { setResponseType } from '../activitypub.js';
import { Users, Followings, UserProfiles } from '@/models/index.js';
import { LessThan } from 'typeorm';
import { IsNull, LessThan } from 'typeorm';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
@@ -27,9 +27,9 @@ export default async (ctx: Router.RouterContext) => {
return;
}
const user = await Users.findOne({
const user = await Users.findOneBy({
id: userId,
host: null,
host: IsNull(),
});
if (user == null) {
@@ -38,7 +38,7 @@ export default async (ctx: Router.RouterContext) => {
}
//#region Check ff visibility
const profile = await UserProfiles.findOneOrFail(user.id);
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
if (profile.ffVisibility === 'private') {
ctx.status = 403;

View File

@@ -9,7 +9,7 @@ import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-c
import renderFollowUser from '@/remote/activitypub/renderer/follow-user.js';
import { setResponseType } from '../activitypub.js';
import { Users, Followings, UserProfiles } from '@/models/index.js';
import { LessThan, FindConditions } from 'typeorm';
import { LessThan, IsNull, FindOptionsWhere } from 'typeorm';
import { Following } from '@/models/entities/following.js';
export default async (ctx: Router.RouterContext) => {
@@ -28,9 +28,9 @@ export default async (ctx: Router.RouterContext) => {
return;
}
const user = await Users.findOne({
const user = await Users.findOneBy({
id: userId,
host: null,
host: IsNull(),
});
if (user == null) {
@@ -39,7 +39,7 @@ export default async (ctx: Router.RouterContext) => {
}
//#region Check ff visibility
const profile = await UserProfiles.findOneOrFail(user.id);
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
if (profile.ffVisibility === 'private') {
ctx.status = 403;
@@ -58,7 +58,7 @@ export default async (ctx: Router.RouterContext) => {
if (page) {
const query = {
followerId: user.id,
} as FindConditions<Following>;
} as FindOptionsWhere<Following>;
// カーソルが指定されている場合
if (cursor) {

View File

@@ -13,7 +13,7 @@ import { countIf } from '@/prelude/array.js';
import * as url from '@/prelude/url.js';
import { Users, Notes } from '@/models/index.js';
import { makePaginationQuery } from '../api/common/make-pagination-query.js';
import { Brackets } from 'typeorm';
import { Brackets, IsNull } from 'typeorm';
import { Note } from '@/models/entities/note.js';
export default async (ctx: Router.RouterContext) => {
@@ -35,9 +35,9 @@ export default async (ctx: Router.RouterContext) => {
return;
}
const user = await Users.findOne({
const user = await Users.findOneBy({
id: userId,
host: null,
host: IsNull(),
});
if (user == null) {
@@ -99,7 +99,7 @@ export default async (ctx: Router.RouterContext) => {
*/
export async function packActivity(note: Note): Promise<any> {
if (note.renoteId && note.text == null && !note.hasPoll && (note.fileIds == null || note.fileIds.length === 0)) {
const renote = await Notes.findOneOrFail(note.renoteId);
const renote = await Notes.findOneByOrFail({ id: note.renoteId });
return renderAnnounce(renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`, note);
}