deps(backend): update typeorm to v1 (#17476)

* deps(backend): update typeorm to v1

* fix

* fix

* attempt to fix test (to be reverted))

* Revert "attempt to fix test (to be reverted))"

This reverts commit 8adf2a1239.

* attempt to fix test

* Revert "attempt to fix test"

This reverts commit 4cf0f5ec9e.

* attempt to fix test

* fix

* fix
This commit is contained in:
かっこかり 2026-05-22 14:27:34 +09:00 committed by GitHub
commit 43534d6213
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 192 additions and 145 deletions

View file

@ -149,7 +149,7 @@
"tinycolor2": "1.6.0",
"tmp": "0.2.5",
"tsc-alias": "1.8.17",
"typeorm": "0.3.30",
"typeorm": "1.0.0",
"ulid": "3.0.2",
"vary": "1.1.2",
"web-push": "3.6.7",

View file

@ -72,7 +72,10 @@ export class CacheService implements OnApplicationShutdown {
this.userMutingsCache = new RedisKVCache<Set<string>>(this.redisClient, 'userMutings', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.mutingsRepository.find({ where: { muterId: key }, select: ['muteeId'] }).then(xs => new Set(xs.map(x => x.muteeId))),
fetcher: (key) => this.mutingsRepository.find({
where: { muterId: key },
select: { muteeId: true },
}).then(xs => new Set(xs.map(x => x.muteeId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),
});
@ -80,7 +83,10 @@ export class CacheService implements OnApplicationShutdown {
this.userBlockingCache = new RedisKVCache<Set<string>>(this.redisClient, 'userBlocking', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.blockingsRepository.find({ where: { blockerId: key }, select: ['blockeeId'] }).then(xs => new Set(xs.map(x => x.blockeeId))),
fetcher: (key) => this.blockingsRepository.find({
where: { blockerId: key },
select: { blockeeId: true },
}).then(xs => new Set(xs.map(x => x.blockeeId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),
});
@ -88,7 +94,10 @@ export class CacheService implements OnApplicationShutdown {
this.userBlockedCache = new RedisKVCache<Set<string>>(this.redisClient, 'userBlocked', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.blockingsRepository.find({ where: { blockeeId: key }, select: ['blockerId'] }).then(xs => new Set(xs.map(x => x.blockerId))),
fetcher: (key) => this.blockingsRepository.find({
where: { blockeeId: key },
select: { blockerId: true },
}).then(xs => new Set(xs.map(x => x.blockerId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),
});
@ -96,7 +105,10 @@ export class CacheService implements OnApplicationShutdown {
this.renoteMutingsCache = new RedisKVCache<Set<string>>(this.redisClient, 'renoteMutings', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.renoteMutingsRepository.find({ where: { muterId: key }, select: ['muteeId'] }).then(xs => new Set(xs.map(x => x.muteeId))),
fetcher: (key) => this.renoteMutingsRepository.find({
where: { muterId: key },
select: { muteeId: true },
}).then(xs => new Set(xs.map(x => x.muteeId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),
});
@ -104,7 +116,10 @@ export class CacheService implements OnApplicationShutdown {
this.userFollowingsCache = new RedisKVCache<Record<string, Pick<MiFollowing, 'withReplies'> | undefined>>(this.redisClient, 'userFollowings', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.followingsRepository.find({ where: { followerId: key }, select: ['followeeId', 'withReplies'] }).then(xs => {
fetcher: (key) => this.followingsRepository.find({
where: { followerId: key },
select: { followeeId: true, withReplies: true },
}).then(xs => {
const obj: Record<string, Pick<MiFollowing, 'withReplies'> | undefined> = {};
for (const x of xs) {
obj[x.followeeId] = { withReplies: x.withReplies };

View file

@ -35,7 +35,7 @@ export class ChannelFollowingService implements OnModuleInit {
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.channelFollowingsRepository.find({
where: { followerId: key },
select: ['followeeId'],
select: { followeeId: true },
}).then(xs => new Set(xs.map(x => x.followeeId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),

View file

@ -34,7 +34,7 @@ export class ChannelMutingService {
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (userId) => this.channelMutingRepository.find({
where: { userId: userId },
select: ['channelId'],
select: { channelId: true },
}).then(xs => new Set(xs.map(x => x.channelId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),

View file

@ -644,7 +644,10 @@ export class ChatService {
@bindThis
public async findRoomById(roomId: MiChatRoom['id']) {
return this.chatRoomsRepository.findOne({ where: { id: roomId }, relations: ['owner'] });
return this.chatRoomsRepository.findOne({
where: { id: roomId },
relations: { owner: true },
});
}
@bindThis
@ -888,7 +891,7 @@ export class ChatService {
const room = message.toRoomId ? await this.chatRoomsRepository.findOneByOrFail({ id: message.toRoomId }) : null;
if (room) {
if (!await this.isRoomMember(room, userId)) {
if (!(await this.isRoomMember(room, userId))) {
throw new Error('cannot react to others message');
}
}

View file

@ -425,7 +425,12 @@ export class CustomEmojiService implements OnApplicationShutdown {
}
const _emojis = emojisQuery.length > 0 ? await this.emojisRepository.find({
where: emojisQuery,
select: ['name', 'host', 'originalUrl', 'publicUrl'],
select: {
name: true,
host: true,
originalUrl: true,
publicUrl: true,
},
}) : [];
for (const emoji of _emojis) {
this.emojisCache.set(`${emoji.name} ${emoji.host}`, emoji);

View file

@ -69,7 +69,10 @@ export class DeleteAccountService {
{ followerSharedInbox: Not(IsNull()) },
{ followeeSharedInbox: Not(IsNull()) },
],
select: ['followerSharedInbox', 'followeeSharedInbox'],
select: {
followerSharedInbox: true,
followeeSharedInbox: true,
},
});
const inboxes = followings.map(x => x.followerSharedInbox ?? x.followeeSharedInbox);

View file

@ -321,7 +321,11 @@ export class NoteCreateService implements OnApplicationShutdown {
// Fetch renote to note
renote = await this.notesRepository.findOne({
where: { id: data.renoteId },
relations: ['user', 'renote', 'reply'],
relations: {
user: true,
renote: true,
reply: true,
},
});
if (renote == null) {
@ -370,14 +374,14 @@ export class NoteCreateService implements OnApplicationShutdown {
// Fetch reply
reply = await this.notesRepository.findOne({
where: { id: data.replyId },
relations: ['user'],
relations: { user: true },
});
if (reply == null) {
throw new IdentifiableError('60142edb-1519-408e-926d-4f108d27bee0', 'No such reply target');
} else if (isRenote(reply) && !isQuote(reply)) {
throw new IdentifiableError('f089e4e2-c0e7-4f60-8a23-e5a6bf786b36', 'Cannot reply to pure renote');
} else if (!await this.noteEntityService.isVisibleForMe(reply, user.id)) {
} else if (!(await this.noteEntityService.isVisibleForMe(reply, user.id))) {
throw new IdentifiableError('11cd37b3-a411-4f77-8633-c580ce6a8dce', 'No such reply target');
} else if (reply.visibility === 'specified' && data.visibility !== 'specified') {
throw new IdentifiableError('ced780a1-2012-4caf-bc7e-a95a291294cb', 'Cannot reply to specified note with different visibility');
@ -572,7 +576,7 @@ export class NoteCreateService implements OnApplicationShutdown {
emojis = data.apEmojis ?? extractCustomEmojisFromMfm(combinedTokens);
mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens);
mentionedUsers = data.apMentions ?? (await this.extractMentionedUsers(user, combinedTokens));
}
// if the host is media-silenced, custom emojis are not allowed
@ -1050,7 +1054,7 @@ export class NoteCreateService implements OnApplicationShutdown {
where: {
followeeId: note.channelId,
},
select: ['followerId'],
select: { followerId: true },
});
for (const channelFollowing of channelFollowings) {
@ -1069,13 +1073,20 @@ export class NoteCreateService implements OnApplicationShutdown {
followerHost: IsNull(),
isFollowerHibernated: false,
},
select: ['followerId', 'withReplies'],
select: {
followerId: true,
withReplies: true,
},
}),
this.userListMembershipsRepository.find({
where: {
userId: user.id,
},
select: ['userListId', 'userListUserId', 'withReplies'],
select: {
userListId: true,
userListUserId: true,
withReplies: true,
},
}),
]);
@ -1183,7 +1194,7 @@ export class NoteCreateService implements OnApplicationShutdown {
id: In(samples.map(x => x.followerId)),
lastActiveDate: LessThan(new Date(Date.now() - (1000 * 60 * 60 * 24 * 50))),
},
select: ['id'],
select: { id: true },
});
if (hibernatedUsers.length > 0) {

View file

@ -103,7 +103,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
{ id: MoreThan(this.idService.gen(Date.now() - 1000 * 60 * 3)), user1Id: me.id, user2Id: targetUser.id, isStarted: false },
{ id: MoreThan(this.idService.gen(Date.now() - 1000 * 60 * 3)), user1Id: targetUser.id, user2Id: me.id, isStarted: false },
],
relations: ['user1', 'user2'],
relations: { user1: true, user2: true },
order: { id: 'DESC' },
});
if (games.length > 0) {
@ -150,7 +150,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
{ id: MoreThan(this.idService.gen(Date.now() - 1000 * 60 * 3)), user1Id: me.id, isStarted: false },
{ id: MoreThan(this.idService.gen(Date.now() - 1000 * 60 * 3)), user2Id: me.id, isStarted: false },
],
relations: ['user1', 'user2'],
relations: { user1: true, user2: true },
order: { id: 'DESC' },
});
if (games.length > 0) {
@ -295,7 +295,12 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
bw: 'random',
isLlotheo: false,
noIrregularRules: options.noIrregularRules,
}, { relations: ['user1', 'user2'] });
}, {
relations: {
user1: true,
user2: true,
},
});
this.cacheGame(game);
const packed = await this.reversiGameEntityService.packDetail(game);
@ -600,7 +605,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
} else {
const game = await this.reversiGamesRepository.findOne({
where: { id },
relations: ['user1', 'user2'],
relations: { user1: true, user2: true },
});
if (game == null) return null;

View file

@ -89,7 +89,7 @@ export class SystemAccountService implements OnApplicationShutdown {
const systemAccount = await this.systemAccountsRepository.findOne({
where: { type: type },
relations: ['user'],
relations: { user: true },
});
if (systemAccount) {

View file

@ -49,7 +49,10 @@ export class UserListService implements OnApplicationShutdown, OnModuleInit {
this.membersCache = new RedisKVCache<Set<string>>(this.redisClient, 'userListMembers', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.userListMembershipsRepository.find({ where: { userListId: key }, select: ['userId'] }).then(xs => new Set(xs.map(x => x.userId))),
fetcher: (key) => this.userListMembershipsRepository.find({
where: { userListId: key },
select: { userId: true },
}).then(xs => new Set(xs.map(x => x.userId))),
toRedisConverter: (value) => JSON.stringify(Array.from(value)),
fromRedisConverter: (value) => new Set(JSON.parse(value)),
});

View file

@ -93,7 +93,10 @@ export class UserSuspendService {
{ followerSharedInbox: Not(IsNull()) },
{ followeeSharedInbox: Not(IsNull()) },
],
select: ['followerSharedInbox', 'followeeSharedInbox'],
select: {
followerSharedInbox: true,
followeeSharedInbox: true,
},
});
const inboxes = followings.map(x => x.followerSharedInbox ?? x.followeeSharedInbox);
@ -123,7 +126,10 @@ export class UserSuspendService {
{ followerSharedInbox: Not(IsNull()) },
{ followeeSharedInbox: Not(IsNull()) },
],
select: ['followerSharedInbox', 'followeeSharedInbox'],
select: {
followerSharedInbox: true,
followeeSharedInbox: true,
},
});
const inboxes = followings.map(x => x.followerSharedInbox ?? x.followeeSharedInbox);

View file

@ -60,7 +60,7 @@ export class ChatEntityService {
for (const record of message.reactions) {
const [userId, reaction] = record.split('/');
reactions.push({
user: packedUsers?.get(userId) ?? await this.userEntityService.pack(userId).catch(() => null),
user: packedUsers?.get(userId) ?? (await this.userEntityService.pack(userId).catch(() => null)),
reaction,
});
}
@ -70,13 +70,13 @@ export class ChatEntityService {
createdAt: this.idService.parse(message.id).date.toISOString(),
text: message.text,
fromUserId: message.fromUserId,
fromUser: packedUsers?.get(message.fromUserId) ?? await this.userEntityService.pack(message.fromUser ?? message.fromUserId, me),
fromUser: packedUsers?.get(message.fromUserId) ?? (await this.userEntityService.pack(message.fromUser ?? message.fromUserId, me)),
toUserId: message.toUserId,
toUser: message.toUserId ? (packedUsers?.get(message.toUserId) ?? await this.userEntityService.pack(message.toUser ?? message.toUserId, me)) : undefined,
toUser: message.toUserId ? (packedUsers?.get(message.toUserId) ?? (await this.userEntityService.pack(message.toUser ?? message.toUserId, me))) : undefined,
toRoomId: message.toRoomId,
toRoom: message.toRoomId ? (packedRooms?.get(message.toRoomId) ?? await this.packRoom(message.toRoom ?? message.toRoomId, me)) : undefined,
toRoom: message.toRoomId ? (packedRooms?.get(message.toRoomId) ?? (await this.packRoom(message.toRoom ?? message.toRoomId, me))) : undefined,
fileId: message.fileId,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? await this.driveFileEntityService.pack(message.file ?? message.fileId)) : null,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? (await this.driveFileEntityService.pack(message.file ?? message.fileId))) : null,
reactions: reactions.filter((r): r is { user: Packed<'UserLite'>; reaction: string; } => r.user != null),
};
}
@ -151,7 +151,7 @@ export class ChatEntityService {
fromUserId: message.fromUserId,
toUserId: message.toUserId!,
fileId: message.fileId,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? await this.driveFileEntityService.pack(message.file ?? message.fileId)) : null,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? (await this.driveFileEntityService.pack(message.file ?? message.fileId))) : null,
reactions,
};
}
@ -191,7 +191,7 @@ export class ChatEntityService {
for (const record of message.reactions) {
const [userId, reaction] = record.split('/');
reactions.push({
user: packedUsers?.get(userId) ?? await this.userEntityService.pack(userId).catch(() => null),
user: packedUsers?.get(userId) ?? (await this.userEntityService.pack(userId).catch(() => null)),
reaction,
});
}
@ -201,10 +201,10 @@ export class ChatEntityService {
createdAt: this.idService.parse(message.id).date.toISOString(),
text: message.text,
fromUserId: message.fromUserId,
fromUser: packedUsers?.get(message.fromUserId) ?? await this.userEntityService.pack(message.fromUser ?? message.fromUserId),
fromUser: packedUsers?.get(message.fromUserId) ?? (await this.userEntityService.pack(message.fromUser ?? message.fromUserId)),
toRoomId: message.toRoomId!,
fileId: message.fileId,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? await this.driveFileEntityService.pack(message.file ?? message.fileId)) : null,
file: message.fileId ? (packedFiles?.get(message.fileId) ?? (await this.driveFileEntityService.pack(message.file ?? message.fileId))) : null,
reactions: reactions.filter((r): r is { user: Packed<'UserLite'>; reaction: string; } => r.user != null),
};
}
@ -248,8 +248,8 @@ export class ChatEntityService {
): Promise<Packed<'ChatRoom'>> {
const room = typeof src === 'object' ? src : await this.chatRoomsRepository.findOneByOrFail({ id: src });
const membership = me && me.id !== room.ownerId ? (options?._hint_?.myMemberships?.get(room.id) ?? await this.chatRoomMembershipsRepository.findOneBy({ roomId: room.id, userId: me.id })) : null;
const invitation = me && me.id !== room.ownerId ? (options?._hint_?.myInvitations?.get(room.id) ?? await this.chatRoomInvitationsRepository.findOneBy({ roomId: room.id, userId: me.id })) : null;
const membership = me && me.id !== room.ownerId ? (options?._hint_?.myMemberships?.get(room.id) ?? (await this.chatRoomMembershipsRepository.findOneBy({ roomId: room.id, userId: me.id }))) : null;
const invitation = me && me.id !== room.ownerId ? (options?._hint_?.myInvitations?.get(room.id) ?? (await this.chatRoomInvitationsRepository.findOneBy({ roomId: room.id, userId: me.id }))) : null;
return {
id: room.id,
@ -257,7 +257,7 @@ export class ChatEntityService {
name: room.name,
description: room.description,
ownerId: room.ownerId,
owner: options?._hint_?.packedOwners.get(room.ownerId) ?? await this.userEntityService.pack(room.owner ?? room.ownerId, me),
owner: options?._hint_?.packedOwners.get(room.ownerId) ?? (await this.userEntityService.pack(room.owner ?? room.ownerId, me)),
isMuted: membership != null ? membership.isMuted : false,
invitationExists: invitation != null,
};
@ -273,12 +273,12 @@ export class ChatEntityService {
const _rooms = rooms.filter((room): room is MiChatRoom => typeof room !== 'string');
if (_rooms.length !== rooms.length) {
_rooms.push(
...await this.chatRoomsRepository.find({
...(await this.chatRoomsRepository.find({
where: {
id: In(rooms.filter((room): room is string => typeof room === 'string')),
},
relations: ['owner'],
}),
relations: { owner: true },
})),
);
}
@ -321,9 +321,9 @@ export class ChatEntityService {
id: invitation.id,
createdAt: this.idService.parse(invitation.id).date.toISOString(),
roomId: invitation.roomId,
room: options?._hint_?.packedRooms.get(invitation.roomId) ?? await this.packRoom(invitation.room ?? invitation.roomId, me),
room: options?._hint_?.packedRooms.get(invitation.roomId) ?? (await this.packRoom(invitation.room ?? invitation.roomId, me)),
userId: invitation.userId,
user: options?._hint_?.packedUsers.get(invitation.userId) ?? await this.userEntityService.pack(invitation.user ?? invitation.userId, me),
user: options?._hint_?.packedUsers.get(invitation.userId) ?? (await this.userEntityService.pack(invitation.user ?? invitation.userId, me)),
};
}
@ -356,9 +356,9 @@ export class ChatEntityService {
id: membership.id,
createdAt: this.idService.parse(membership.id).date.toISOString(),
userId: membership.userId,
user: options?.populateUser ? (options._hint_?.packedUsers.get(membership.userId) ?? await this.userEntityService.pack(membership.user ?? membership.userId, me)) : undefined,
user: options?.populateUser ? (options._hint_?.packedUsers.get(membership.userId) ?? (await this.userEntityService.pack(membership.user ?? membership.userId, me))) : undefined,
roomId: membership.roomId,
room: options?.populateRoom ? (options._hint_?.packedRooms.get(membership.roomId) ?? await this.packRoom(membership.room ?? membership.roomId, me)) : undefined,
room: options?.populateRoom ? (options._hint_?.packedRooms.get(membership.roomId) ?? (await this.packRoom(membership.room ?? membership.roomId, me))) : undefined,
};
}

View file

@ -38,7 +38,10 @@ export class InviteCodeEntityService {
where: {
id: src,
},
relations: ['createdBy', 'usedBy'],
relations: {
createdBy: true,
usedBy: true,
},
});
return await awaitAll({
@ -46,8 +49,8 @@ export class InviteCodeEntityService {
code: target.code,
expiresAt: target.expiresAt ? target.expiresAt.toISOString() : null,
createdAt: this.idService.parse(target.id).date.toISOString(),
createdBy: target.createdBy ? hints?.packedCreatedBy ?? await this.userEntityService.pack(target.createdBy, me) : null,
usedBy: target.usedBy ? hints?.packedUsedBy ?? await this.userEntityService.pack(target.usedBy, me) : null,
createdBy: target.createdBy ? hints?.packedCreatedBy ?? (await this.userEntityService.pack(target.createdBy, me)) : null,
usedBy: target.usedBy ? hints?.packedUsedBy ?? (await this.userEntityService.pack(target.usedBy, me)) : null,
usedAt: target.usedAt ? target.usedAt.toISOString() : null,
used: !!target.usedAt,
});

View file

@ -184,7 +184,9 @@ export class NoteDraftEntityService implements OnModuleInit {
private findNoteDraftOrFail(id: string): Promise<MiNoteDraft> {
return this.noteDraftsRepository.findOneOrFail({
where: { id },
relations: ['user'],
relations: {
user: true,
},
});
}
}

View file

@ -462,7 +462,7 @@ export class NoteEntityService implements OnModuleInit {
this.treatVisibility(packed);
if (!opts.skipHide && await this.shouldHideNote(packed, meId)) {
if (!opts.skipHide && (await this.shouldHideNote(packed, meId))) {
this.hideNote(packed);
}
@ -589,7 +589,11 @@ export class NoteEntityService implements OnModuleInit {
private findNoteOrFail(id: string): Promise<MiNote> {
return this.notesRepository.findOneOrFail({
where: { id },
relations: ['user', 'renote', 'reply'],
relations: {
user: true,
renote: true,
reply: true,
},
});
}

View file

@ -210,7 +210,15 @@ export class NotificationEntityService implements OnModuleInit {
const noteIds = validNotifications.map(x => 'noteId' in x ? x.noteId : null).filter(x => x != null);
const notes = noteIds.length > 0 ? await this.notesRepository.find({
where: { id: In(noteIds) },
relations: ['user', 'reply', 'reply.user', 'renote', 'renote.user'],
relations: {
user: true,
reply: {
user: true,
},
renote: {
user: true,
},
},
}) : [];
const packedNotesArray = await this.noteEntityService.packMany(notes, { id: meId }, {
detail: true,

View file

@ -271,6 +271,10 @@ export function createPostgresDataSource(config: Config) {
statement_timeout: 1000 * 10,
...config.db.extra,
},
invalidWhereValuesBehavior: {
null: 'ignore',
undefined: 'ignore',
},
...(config.dbReplications ? {
replication: {
master: {

View file

@ -31,7 +31,10 @@ export class PostScheduledNoteProcessorService {
@bindThis
public async process(job: Bull.Job<PostScheduledNoteJobData>): Promise<void> {
const draft = await this.noteDraftsRepository.findOne({ where: { id: job.data.noteDraftId }, relations: ['user'] });
const draft = await this.noteDraftsRepository.findOne({
where: { id: job.data.noteDraftId },
relations: { user: true },
});
if (draft == null || draft.user == null || draft.scheduledAt == null || !draft.isActuallyScheduled) {
return;
}

View file

@ -145,7 +145,7 @@ export class ApiServerService {
fastify.get('/v1/instance/peers', async (request, reply) => {
const instances = await this.instancesRepository.find({
select: ['host'],
select: { host: true },
where: {
suspensionState: 'none',
},

View file

@ -41,7 +41,18 @@ export class GetterService {
@bindThis
public async getNoteWithRelations(noteId: MiNote['id']) {
const note = await this.notesRepository.findOne({ where: { id: noteId }, relations: ['user', 'reply', 'renote', 'reply.user', 'renote.user'] });
const note = await this.notesRepository.findOne({
where: { id: noteId },
relations: {
user: true,
reply: {
user: true,
},
renote: {
user: true,
},
},
});
if (note == null) {
throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.');

View file

@ -50,7 +50,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
super(meta, paramDef, async (ps, me) => {
const profile = await this.userProfilesRepository.findOne({
where: { email: ps.email },
relations: ['user'],
relations: { user: true },
});
if (profile == null) {

View file

@ -68,7 +68,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
score: 'DESC',
},
take: 10,
relations: ['user'],
relations: { user: true },
});
const users = await this.userEntityService.packMany(records.map(r => r.user!), null);

View file

@ -57,7 +57,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
where: {
userId: user.id,
},
relations: ['user'],
relations: { user: true },
});
if (userProfile == null) {

View file

@ -67,7 +67,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
where: {
userId: me.id,
},
relations: ['user'],
relations: { user: true },
});
if (profile == null) {

View file

@ -84,7 +84,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
id: -1,
},
take: 1000,
select: ['replyId'],
select: { replyId: true },
});
// 投稿が少なかったら中断
@ -97,7 +97,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
where: {
id: In(recentNotes.map(p => p.replyId)),
},
select: ['userId'],
select: { userId: true },
});
const repliedUsers: any = {};
@ -124,7 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const _userMap = await this.userEntityService.packMany(topRepliedUserIds, me, { schema: 'UserDetailed' })
.then(users => new Map(users.map(u => [u.id, u])));
const repliesObj = await Promise.all(topRepliedUserIds.map(async (userId) => ({
user: _userMap.get(userId) ?? await this.userEntityService.pack(userId, me, { schema: 'UserDetailed' }),
user: _userMap.get(userId) ?? (await this.userEntityService.pack(userId, me, { schema: 'UserDetailed' })),
weight: repliedUsers[userId] / peak,
})));

View file

@ -77,7 +77,7 @@ export class UserListChannel extends Channel {
where: {
userListId: this.listId,
},
select: ['userId'],
select: { userId: true },
});
const membershipsMap: Record<string, Pick<MiUserListMembership, 'withReplies'> | undefined> = {};

View file

@ -441,7 +441,7 @@ export class ClientServerService {
img: this.meta.bannerUrl ?? undefined,
title: this.meta.name ?? 'Misskey',
desc: this.meta.description ?? undefined,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
...data,
}));
};
@ -458,7 +458,7 @@ export class ClientServerService {
requireSigninToViewContents: false,
});
return user && await this.feedService.packFeed(user);
return user && (await this.feedService.packFeed(user));
};
// Atom
@ -541,7 +541,7 @@ export class ClientServerService {
user: _user,
profile,
sub: request.params.sub,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
clientCtxJson: htmlSafeJsonStringify({
user: _user,
}),
@ -579,7 +579,11 @@ export class ClientServerService {
id: request.params.note,
visibility: In(['public', 'home']),
},
relations: ['user', 'reply', 'renote'],
relations: {
user: true,
reply: true,
renote: true,
},
});
if (
@ -599,7 +603,7 @@ export class ClientServerService {
return await HtmlTemplateService.replyHtml(reply, NotePage({
note: _note,
profile,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
clientCtxJson: htmlSafeJsonStringify({
note: _note,
}),
@ -639,7 +643,7 @@ export class ClientServerService {
return await HtmlTemplateService.replyHtml(reply, PagePage({
page: _page,
profile,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
} else {
return await renderBase(reply);
@ -663,7 +667,7 @@ export class ClientServerService {
return await HtmlTemplateService.replyHtml(reply, FlashPage({
flash: _flash,
profile,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
} else {
return await renderBase(reply);
@ -687,7 +691,7 @@ export class ClientServerService {
return await HtmlTemplateService.replyHtml(reply, ClipPage({
clip: _clip,
profile,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
clientCtxJson: htmlSafeJsonStringify({
clip: _clip,
}),
@ -712,7 +716,7 @@ export class ClientServerService {
return await HtmlTemplateService.replyHtml(reply, GalleryPostPage({
galleryPost: _post,
profile,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
} else {
return await renderBase(reply);
@ -730,7 +734,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=15');
return await HtmlTemplateService.replyHtml(reply, ChannelPage({
channel: _channel,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
} else {
return await renderBase(reply);
@ -748,7 +752,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=3600');
return await HtmlTemplateService.replyHtml(reply, ReversiGamePage({
reversiGame: _game,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
} else {
return await renderBase(reply);
@ -767,7 +771,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=3600');
return await HtmlTemplateService.replyHtml(reply, AnnouncementPage({
announcement: _announcement,
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
} else {
return await renderBase(reply);
@ -803,7 +807,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=3600');
return await HtmlTemplateService.replyHtml(reply, BaseEmbed({
title: this.meta.name ?? 'Misskey',
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
embedCtxJson: htmlSafeJsonStringify({
user: _user,
}),
@ -817,7 +821,11 @@ export class ClientServerService {
where: {
id: request.params.note,
},
relations: ['user', 'reply', 'renote'],
relations: {
user: true,
reply: true,
renote: true,
},
});
if (note == null) return;
@ -829,7 +837,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=3600');
return await HtmlTemplateService.replyHtml(reply, BaseEmbed({
title: this.meta.name ?? 'Misskey',
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
embedCtxJson: htmlSafeJsonStringify({
note: _note,
}),
@ -850,7 +858,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=3600');
return await HtmlTemplateService.replyHtml(reply, BaseEmbed({
title: this.meta.name ?? 'Misskey',
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
embedCtxJson: htmlSafeJsonStringify({
clip: _clip,
}),
@ -863,7 +871,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=3600');
return await HtmlTemplateService.replyHtml(reply, BaseEmbed({
title: this.meta.name ?? 'Misskey',
...await this.htmlTemplateService.getCommonData(),
...(await this.htmlTemplateService.getCommonData()),
}));
});

79
pnpm-lock.yaml generated
View file

@ -379,8 +379,8 @@ importers:
specifier: 1.8.17
version: 1.8.17
typeorm:
specifier: 0.3.30
version: 0.3.30(ioredis@5.10.1)(pg@8.20.0)
specifier: 1.0.0
version: 1.0.0(ioredis@5.10.1)(pg@8.20.0)
ulid:
specifier: 3.0.2
version: 3.0.2
@ -4898,10 +4898,6 @@ packages:
resolution: {integrity: sha512-HqZ5rWlFjGiV0tDm3UxxgNRqsOTniqoKZu0pIAfh7TZQMGuZK+hH0drySty0si0QXj1ieop4+SkSfPZBPPkHig==}
engines: {node: '>=14'}
app-root-path@3.1.0:
resolution: {integrity: sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==}
engines: {node: '>= 6.0.0'}
append-field@1.0.0:
resolution: {integrity: sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==}
@ -5879,10 +5875,6 @@ packages:
domutils@3.2.2:
resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==}
dotenv@16.6.1:
resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==}
engines: {node: '>=12'}
dunder-proto@1.0.1:
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
engines: {node: '>= 0.4'}
@ -9081,11 +9073,6 @@ packages:
setprototypeof@1.2.0:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
sha.js@2.4.12:
resolution: {integrity: sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w==}
engines: {node: '>= 0.10'}
hasBin: true
sharp@0.33.5:
resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==}
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
@ -9611,10 +9598,6 @@ packages:
resolution: {integrity: sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==}
engines: {node: '>=14.14'}
to-buffer@1.2.2:
resolution: {integrity: sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==}
engines: {node: '>= 0.4'}
to-data-view@1.1.0:
resolution: {integrity: sha512-1eAdufMg6mwgmlojAx3QeMnzB/BTVp7Tbndi3U7ftcT2zCZadjxkkmLmd97zmaxWi+sgGcgWrokmpEoy0Dn0vQ==}
@ -9795,27 +9778,26 @@ packages:
typedarray@0.0.6:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
typeorm@0.3.30:
resolution: {integrity: sha512-8T35PzjefOdqc2ZR9mwLQj0pUGp6lQhMbK2EvVMwJVJWlaoHm0v/Q6dThNOZkFchD+0yMg8gwjKM28ePiLSXSQ==}
engines: {node: '>=16.13.0'}
typeorm@1.0.0:
resolution: {integrity: sha512-2mSKNqucP8vo+xQLP59xlHUcqLvG6qajxA7q7tnhJgeZjTrA6lK/Ar7LRyiAxdXhyXmGbIPsArPmcUB9Xg+M7w==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24.11.0}
hasBin: true
peerDependencies:
'@google-cloud/spanner': ^5.18.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
'@google-cloud/spanner': ^8.0.0
'@sap/hana-client': ^2.14.22
better-sqlite3: ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0
better-sqlite3: ^12.0.0
ioredis: ^5.0.4
mongodb: ^5.8.0 || ^6.0.0
mssql: ^9.1.1 || ^10.0.0 || ^11.0.0 || ^12.0.0
mysql2: ^2.2.5 || ^3.0.1
mongodb: ^7.0.0
mssql: ^12.0.0
mysql2: ^3.15.3
oracledb: ^6.3.0
pg: ^8.5.1
pg-native: ^3.0.0
pg-query-stream: ^4.0.0
redis: ^3.1.1 || ^4.0.0 || ^5.0.14
redis: ^5.0.0
sql.js: ^1.4.0
sqlite3: ^5.0.3
ts-node: ^10.7.0
typeorm-aurora-data-api-driver: ^2.0.0 || ^3.0.0
ts-node: ^10.9.2
typeorm-aurora-data-api-driver: ^3.0.0
peerDependenciesMeta:
'@google-cloud/spanner':
optional: true
@ -9843,8 +9825,6 @@ packages:
optional: true
sql.js:
optional: true
sqlite3:
optional: true
ts-node:
optional: true
typeorm-aurora-data-api-driver:
@ -9971,10 +9951,6 @@ packages:
resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==}
hasBin: true
uuid@11.1.1:
resolution: {integrity: sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==}
hasBin: true
uuid@14.0.0:
resolution: {integrity: sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg==}
hasBin: true
@ -14189,8 +14165,6 @@ snapshots:
ansis@4.2.0: {}
app-root-path@3.1.0: {}
append-field@1.0.0: {}
aproba@2.1.0:
@ -15246,8 +15220,6 @@ snapshots:
domelementtype: 2.3.0
domhandler: 5.0.3
dotenv@16.6.1: {}
dunder-proto@1.0.1:
dependencies:
call-bind-apply-helpers: 1.0.2
@ -18985,12 +18957,6 @@ snapshots:
setprototypeof@1.2.0: {}
sha.js@2.4.12:
dependencies:
inherits: 2.0.4
safe-buffer: 5.2.1
to-buffer: 1.2.2
sharp@0.33.5:
dependencies:
color: 4.2.3
@ -19572,12 +19538,6 @@ snapshots:
tmp@0.2.5: {}
to-buffer@1.2.2:
dependencies:
isarray: 2.0.5
safe-buffer: 5.2.1
typed-array-buffer: 1.0.3
to-data-view@1.1.0: {}
to-regex-range@5.0.1:
@ -19753,23 +19713,18 @@ snapshots:
typedarray@0.0.6: {}
typeorm@0.3.30(ioredis@5.10.1)(pg@8.20.0):
typeorm@1.0.0(ioredis@5.10.1)(pg@8.20.0):
dependencies:
'@sqltools/formatter': 1.2.5
ansis: 4.2.0
app-root-path: 3.1.0
buffer: 6.0.3
dayjs: 1.11.20
debug: 4.4.3(supports-color@10.2.2)
dedent: 1.7.2
dotenv: 16.6.1
glob: 10.5.0
reflect-metadata: 0.2.2
sha.js: 2.4.12
sql-highlight: 6.1.0
tinyglobby: 0.2.16
tslib: 2.8.1
uuid: 11.1.1
yargs: 17.7.2
yargs: 18.0.0
optionalDependencies:
ioredis: 5.10.1
pg: 8.20.0
@ -19890,8 +19845,6 @@ snapshots:
uuid@11.1.0: {}
uuid@11.1.1: {}
uuid@14.0.0: {}
uuid@9.0.1: {}