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:
@@ -20,7 +20,7 @@ export const paramDef = {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const token = ps.token.replace(/\s/g, '');
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
if (profile.twoFactorTempSecret == null) {
|
||||
throw new Error('二段階認証の設定が開始されていません');
|
||||
|
@@ -35,7 +35,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
@@ -96,7 +96,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||
});
|
||||
if (!verificationData.valid) throw new Error('signature invalid');
|
||||
|
||||
const attestationChallenge = await AttestationChallenges.findOne({
|
||||
const attestationChallenge = await AttestationChallenges.findOneBy({
|
||||
userId: user.id,
|
||||
id: ps.challengeId,
|
||||
registrationChallenge: true,
|
||||
|
@@ -24,7 +24,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
|
@@ -21,7 +21,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
|
@@ -20,7 +20,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
|
@@ -18,7 +18,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
|
@@ -19,7 +19,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.currentPassword, profile.password!);
|
||||
|
@@ -21,8 +21,8 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const userDetailed = await Users.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
const userDetailed = await Users.findOneByOrFail({ id: user.id });
|
||||
if (userDetailed.isDeleted) {
|
||||
return;
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ export const paramDef = {
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
return {
|
||||
count: await MutedNotes.count({
|
||||
count: await MutedNotes.countBy({
|
||||
userId: user.id,
|
||||
reason: 'word',
|
||||
}),
|
||||
|
@@ -50,7 +50,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const file = await DriveFiles.findOne(ps.fileId);
|
||||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
|
@@ -49,7 +49,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const file = await DriveFiles.findOne(ps.fileId);
|
||||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
|
@@ -50,7 +50,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const file = await DriveFiles.findOne(ps.fileId);
|
||||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
|
@@ -49,7 +49,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const file = await DriveFiles.findOne(ps.fileId);
|
||||
const file = await DriveFiles.findOneBy({ id: ps.fileId });
|
||||
|
||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
//if (!file.type.endsWith('/csv')) throw new ApiError(meta.errors.unexpectedFileType);
|
||||
|
@@ -26,7 +26,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||
isRead: true,
|
||||
});
|
||||
|
||||
const joinings = await UserGroupJoinings.find({ userId: user.id });
|
||||
const joinings = await UserGroupJoinings.findBy({ userId: user.id });
|
||||
|
||||
await Promise.all(joinings.map(j => MessagingMessages.createQueryBuilder().update()
|
||||
.set({
|
||||
|
@@ -31,14 +31,14 @@ export const paramDef = {
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
// Check if announcement exists
|
||||
const announcement = await Announcements.findOne(ps.announcementId);
|
||||
const announcement = await Announcements.findOneBy({ id: ps.announcementId });
|
||||
|
||||
if (announcement == null) {
|
||||
throw new ApiError(meta.errors.noSuchAnnouncement);
|
||||
}
|
||||
|
||||
// Check if already read
|
||||
const read = await AnnouncementReads.findOne({
|
||||
const read = await AnnouncementReads.findOneBy({
|
||||
announcementId: ps.announcementId,
|
||||
userId: user.id,
|
||||
});
|
||||
|
@@ -20,10 +20,10 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const freshUser = await Users.findOneOrFail(user.id);
|
||||
const freshUser = await Users.findOneByOrFail({ id: user.id });
|
||||
const oldToken = freshUser.token;
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
|
@@ -18,7 +18,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const token = await AccessTokens.findOne(ps.tokenId);
|
||||
const token = await AccessTokens.findOneBy({ id: ps.tokenId });
|
||||
|
||||
if (token) {
|
||||
await AccessTokens.delete({
|
||||
|
@@ -45,7 +45,7 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
// Compare password
|
||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||
|
@@ -121,13 +121,13 @@ export const paramDef = {
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, _user, token) => {
|
||||
const user = await Users.findOneOrFail(_user.id);
|
||||
const user = await Users.findOneByOrFail({ id: _user.id });
|
||||
const isSecure = token == null;
|
||||
|
||||
const updates = {} as Partial<User>;
|
||||
const profileUpdates = {} as Partial<UserProfile>;
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
if (ps.name !== undefined) updates.name = ps.name;
|
||||
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
||||
@@ -171,21 +171,21 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
||||
if (ps.emailNotificationTypes !== undefined) profileUpdates.emailNotificationTypes = ps.emailNotificationTypes;
|
||||
|
||||
if (ps.avatarId) {
|
||||
const avatar = await DriveFiles.findOne(ps.avatarId);
|
||||
const avatar = await DriveFiles.findOneBy({ id: ps.avatarId });
|
||||
|
||||
if (avatar == null || avatar.userId !== user.id) throw new ApiError(meta.errors.noSuchAvatar);
|
||||
if (!avatar.type.startsWith('image/')) throw new ApiError(meta.errors.avatarNotAnImage);
|
||||
}
|
||||
|
||||
if (ps.bannerId) {
|
||||
const banner = await DriveFiles.findOne(ps.bannerId);
|
||||
const banner = await DriveFiles.findOneBy({ id: ps.bannerId });
|
||||
|
||||
if (banner == null || banner.userId !== user.id) throw new ApiError(meta.errors.noSuchBanner);
|
||||
if (!banner.type.startsWith('image/')) throw new ApiError(meta.errors.bannerNotAnImage);
|
||||
}
|
||||
|
||||
if (ps.pinnedPageId) {
|
||||
const page = await Pages.findOne(ps.pinnedPageId);
|
||||
const page = await Pages.findOneBy({ id: ps.pinnedPageId });
|
||||
|
||||
if (page == null || page.userId !== user.id) throw new ApiError(meta.errors.noSuchPage);
|
||||
|
||||
@@ -238,7 +238,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
||||
|
||||
// Publish meUpdated event
|
||||
publishMainStream(user.id, 'meUpdated', iObj);
|
||||
publishUserEvent(user.id, 'updateUserProfile', await UserProfiles.findOne(user.id));
|
||||
publishUserEvent(user.id, 'updateUserProfile', await UserProfiles.findOneBy({ userId: user.id }));
|
||||
|
||||
// 鍵垢を解除したとき、溜まっていたフォローリクエストがあるならすべて承認
|
||||
if (user.isLocked && ps.isLocked === false) {
|
||||
|
Reference in New Issue
Block a user