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

@ -24,13 +24,13 @@ export default class DbResolver {
const parsed = this.parseUri(value);
if (parsed.id) {
return (await Notes.findOne({
return (await Notes.findOneBy({
id: parsed.id,
})) || null;
}
if (parsed.uri) {
return (await Notes.findOne({
return (await Notes.findOneBy({
uri: parsed.uri,
})) || null;
}
@ -42,13 +42,13 @@ export default class DbResolver {
const parsed = this.parseUri(value);
if (parsed.id) {
return (await MessagingMessages.findOne({
return (await MessagingMessages.findOneBy({
id: parsed.id,
})) || null;
}
if (parsed.uri) {
return (await MessagingMessages.findOne({
return (await MessagingMessages.findOneBy({
uri: parsed.uri,
})) || null;
}
@ -63,13 +63,13 @@ export default class DbResolver {
const parsed = this.parseUri(value);
if (parsed.id) {
return (await Users.findOne({
return (await Users.findOneBy({
id: parsed.id,
})) || null;
}
if (parsed.uri) {
return (await Users.findOne({
return (await Users.findOneBy({
uri: parsed.uri,
})) || null;
}
@ -85,7 +85,7 @@ export default class DbResolver {
key: UserPublickey;
} | null> {
const key = await publicKeyCache.fetch(keyId, async () => {
const key = await UserPublickeys.findOne({
const key = await UserPublickeys.findOneBy({
keyId,
});
@ -97,7 +97,7 @@ export default class DbResolver {
if (key == null) return null;
return {
user: await userByIdCache.fetch(key.userId, () => Users.findOneOrFail(key.userId)) as CacheableRemoteUser,
user: await userByIdCache.fetch(key.userId, () => Users.findOneByOrFail({ id: key.userId })) as CacheableRemoteUser,
key,
};
}
@ -113,7 +113,7 @@ export default class DbResolver {
if (user == null) return null;
const key = await publicKeyByUserIdCache.fetch(user.id, () => UserPublickeys.findOne(user.id).then(x => x || null), v => v != null); // TODO: typeorm 3.0 にしたら.then(x => x || null)は消せる
const key = await publicKeyByUserIdCache.fetch(user.id, () => UserPublickeys.findOneBy({ userId: user.id }), v => v != null);
return {
user,