1
0

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
@@ -45,7 +45,7 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
}
});
const req = await FollowRequests.findOne({
const req = await FollowRequests.findOneBy({
followeeId: followee.id,
followerId: follower.id,
});
@@ -108,17 +108,17 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
export default async function(_follower: { id: User['id'] }, _followee: { id: User['id'] }, requestId?: string) {
const [follower, followee] = await Promise.all([
Users.findOneOrFail(_follower.id),
Users.findOneOrFail(_followee.id),
Users.findOneByOrFail({ id: _follower.id }),
Users.findOneByOrFail({ id: _followee.id }),
]);
// check blocking
const [blocking, blocked] = await Promise.all([
Blockings.findOne({
Blockings.findOneBy({
blockerId: follower.id,
blockeeId: followee.id,
}),
Blockings.findOne({
Blockings.findOneBy({
blockerId: followee.id,
blockeeId: follower.id,
}),
@@ -138,7 +138,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us
if (blocked != null) throw new IdentifiableError('3338392a-f764-498d-8855-db939dcf8c48', 'blocked');
}
const followeeProfile = await UserProfiles.findOneOrFail(followee.id);
const followeeProfile = await UserProfiles.findOneByOrFail({ userId: followee.id });
// フォロー対象が鍵アカウントである or
// フォロワーがBotであり、フォロー対象がBotからのフォローに慎重である or
@@ -148,7 +148,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us
let autoAccept = false;
// 鍵アカウントであっても、既にフォローされていた場合はスルー
const following = await Followings.findOne({
const following = await Followings.findOneBy({
followerId: follower.id,
followeeId: followee.id,
});
@@ -158,7 +158,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us
// フォローしているユーザーは自動承認オプション
if (!autoAccept && (Users.isLocalUser(followee) && followeeProfile.autoAcceptFollowed)) {
const followed = await Followings.findOne({
const followed = await Followings.findOneBy({
followerId: followee.id,
followeeId: follower.id,
});
@@ -13,7 +13,7 @@ import { instanceChart, perUserFollowingChart } from '@/services/chart/index.js'
const logger = new Logger('following/delete');
export default async function(follower: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }, followee: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }, silent = false) {
const following = await Followings.findOne({
const following = await Followings.findOneBy({
followerId: follower.id,
followeeId: followee.id,
});
@@ -63,7 +63,7 @@ export async function remoteReject(actor: Remote, follower: Local) {
* Remove follow request record
*/
async function removeFollowRequest(followee: Both, follower: Both) {
const request = await FollowRequests.findOne({
const request = await FollowRequests.findOneBy({
followeeId: followee.id,
followerId: follower.id,
});
@@ -77,7 +77,7 @@ async function removeFollowRequest(followee: Both, follower: Both) {
* Remove follow record
*/
async function removeFollow(followee: Both, follower: Both) {
const following = await Followings.findOne({
const following = await Followings.findOneBy({
followeeId: followee.id,
followerId: follower.id,
});
@@ -92,7 +92,7 @@ async function removeFollow(followee: Both, follower: Both) {
* Deliver Reject to remote
*/
async function deliverReject(followee: Local, follower: Remote) {
const request = await FollowRequests.findOne({
const request = await FollowRequests.findOneBy({
followeeId: followee.id,
followerId: follower.id,
});
@@ -7,12 +7,12 @@ import { FollowRequests, Users } from '@/models/index.js';
* @param user ユーザー
*/
export default async function(user: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }) {
const requests = await FollowRequests.find({
const requests = await FollowRequests.findBy({
followeeId: user.id,
});
for (const request of requests) {
const follower = await Users.findOneOrFail(request.followerId);
const follower = await Users.findOneByOrFail({ id: request.followerId });
accept(user, follower);
}
}
@@ -9,7 +9,7 @@ import { FollowRequests, Users } from '@/models/index.js';
import { IdentifiableError } from '@/misc/identifiable-error.js';
export default async function(followee: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }, follower: User) {
const request = await FollowRequests.findOne({
const request = await FollowRequests.findOneBy({
followeeId: followee.id,
followerId: follower.id,
});
@@ -16,7 +16,7 @@ export default async function(followee: { id: User['id']; host: User['host']; ur
}
}
const request = await FollowRequests.findOne({
const request = await FollowRequests.findOneBy({
followeeId: followee.id,
followerId: follower.id,
});
@@ -12,11 +12,11 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
// check blocking
const [blocking, blocked] = await Promise.all([
Blockings.findOne({
Blockings.findOneBy({
blockerId: follower.id,
blockeeId: followee.id,
}),
Blockings.findOne({
Blockings.findOneBy({
blockerId: followee.id,
blockeeId: follower.id,
}),
@@ -39,7 +39,7 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
followeeHost: followee.host,
followeeInbox: Users.isRemoteUser(followee) ? followee.inbox : undefined,
followeeSharedInbox: Users.isRemoteUser(followee) ? followee.sharedInbox : undefined,
}).then(x => FollowRequests.findOneOrFail(x.identifiers[0]));
}).then(x => FollowRequests.findOneByOrFail(x.identifiers[0]));
// Publish receiveRequest event
if (Users.isLocalUser(followee)) {