From 2db5b61616194b33468a057489e7c1d4597f5cc8 Mon Sep 17 00:00:00 2001 From: zyoshoka <107108195+zyoshoka@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:45:35 +0900 Subject: [PATCH] =?UTF-8?q?refactor(backend):=20User=E9=96=A2=E9=80=A3?= =?UTF-8?q?=E3=81=AE=E3=82=B9=E3=82=AD=E3=83=BC=E3=83=9E/=E5=9E=8B?= =?UTF-8?q?=E3=81=AE=E6=8C=87=E5=AE=9A=E3=82=92=E5=BC=B7=E3=81=8F=E3=81=99?= =?UTF-8?q?=E3=82=8B=20(#12808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(backend): User関連のスキーマ/型の指定を強くする * refactor(backend): `pack()`の引数にスキーマを指定するように * chore: fix ci * fix: 変更漏れ * fix ci --------- Co-authored-by: syuilo --- .../backend/src/core/AccountMoveService.ts | 2 +- .../backend/src/core/GlobalEventService.ts | 14 +++--- .../backend/src/core/UserBlockingService.ts | 4 +- .../backend/src/core/UserFollowingService.ts | 14 +++--- .../entities/AbuseUserReportEntityService.ts | 6 +-- .../core/entities/BlockingEntityService.ts | 2 +- .../src/core/entities/FlashEntityService.ts | 2 +- .../core/entities/FollowingEntityService.ts | 4 +- .../entities/ModerationLogEntityService.ts | 2 +- .../src/core/entities/MutingEntityService.ts | 2 +- .../src/core/entities/NoteEntityService.ts | 4 +- .../entities/NotificationEntityService.ts | 28 ++++-------- .../src/core/entities/PageEntityService.ts | 2 +- .../entities/RenoteMutingEntityService.ts | 2 +- .../src/core/entities/UserEntityService.ts | 43 ++++++++----------- .../src/models/json-schema/blocking.ts | 2 +- .../src/models/json-schema/following.ts | 4 +- .../backend/src/models/json-schema/muting.ts | 2 +- .../src/models/json-schema/renote-muting.ts | 2 +- .../backend/src/models/json-schema/user.ts | 8 ---- packages/backend/src/server/ServerService.ts | 2 +- .../src/server/api/ApiServerService.ts | 2 +- .../src/server/api/SignupApiService.ts | 2 +- .../api/endpoints/admin/abuse-user-reports.ts | 6 +-- .../api/endpoints/admin/accounts/create.ts | 9 ++-- .../endpoints/admin/accounts/find-by-email.ts | 4 +- .../server/api/endpoints/admin/roles/users.ts | 4 +- .../endpoints/admin/show-moderation-logs.ts | 2 +- .../server/api/endpoints/admin/show-users.ts | 2 +- .../src/server/api/endpoints/ap/show.ts | 2 +- .../api/endpoints/auth/session/userkey.ts | 2 +- .../server/api/endpoints/blocking/create.ts | 2 +- .../server/api/endpoints/blocking/delete.ts | 2 +- .../api/endpoints/bubble-game/ranking.ts | 2 +- .../server/api/endpoints/federation/users.ts | 2 +- .../server/api/endpoints/hashtags/users.ts | 2 +- .../backend/src/server/api/endpoints/i.ts | 4 +- .../src/server/api/endpoints/i/2fa/done.ts | 2 +- .../server/api/endpoints/i/2fa/key-done.ts | 2 +- .../api/endpoints/i/2fa/password-less.ts | 2 +- .../server/api/endpoints/i/2fa/remove-key.ts | 2 +- .../server/api/endpoints/i/2fa/unregister.ts | 2 +- .../server/api/endpoints/i/2fa/update-key.ts | 2 +- .../backend/src/server/api/endpoints/i/pin.ts | 4 +- .../src/server/api/endpoints/i/unpin.ts | 4 +- .../server/api/endpoints/i/update-email.ts | 4 +- .../src/server/api/endpoints/i/update.ts | 4 +- .../src/server/api/endpoints/page-push.ts | 2 +- .../src/server/api/endpoints/pinned-users.ts | 2 +- .../src/server/api/endpoints/roles/users.ts | 6 +-- .../backend/src/server/api/endpoints/users.ts | 2 +- .../users/get-frequently-replied-users.ts | 2 +- .../endpoints/users/lists/get-memberships.ts | 2 +- .../api/endpoints/users/recommendation.ts | 2 +- .../users/search-by-username-and-host.ts | 2 +- .../src/server/api/endpoints/users/search.ts | 2 +- .../src/server/api/endpoints/users/show.ts | 4 +- packages/misskey-js/etc/misskey-js.api.md | 2 +- .../misskey-js/src/autogen/apiClientJSDoc.ts | 4 +- packages/misskey-js/src/autogen/endpoint.ts | 4 +- packages/misskey-js/src/autogen/entities.ts | 4 +- packages/misskey-js/src/autogen/models.ts | 4 +- packages/misskey-js/src/autogen/types.ts | 34 +++++++-------- packages/misskey-js/src/entities.ts | 4 +- 64 files changed, 141 insertions(+), 169 deletions(-) diff --git a/packages/backend/src/core/AccountMoveService.ts b/packages/backend/src/core/AccountMoveService.ts index 350aa6ba24..9d4d9219ef 100644 --- a/packages/backend/src/core/AccountMoveService.ts +++ b/packages/backend/src/core/AccountMoveService.ts @@ -96,7 +96,7 @@ export class AccountMoveService { await this.apDeliverManagerService.deliverToFollowers(src, moveAct); // Publish meUpdated event - const iObj = await this.userEntityService.pack(src.id, src, { detail: true, includeSecrets: true }); + const iObj = await this.userEntityService.pack(src.id, src, { schema: 'MeDetailed', includeSecrets: true }); this.globalEventService.publishMainStream(src.id, 'meUpdated', iObj); // Unfollow after 24 hours diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts index 6a72671665..45ee97384e 100644 --- a/packages/backend/src/core/GlobalEventService.ts +++ b/packages/backend/src/core/GlobalEventService.ts @@ -54,15 +54,15 @@ export interface MainEventTypes { reply: Packed<'Note'>; renote: Packed<'Note'>; follow: Packed<'UserDetailedNotMe'>; - followed: Packed<'UserDetailed' | 'UserLite'>; - unfollow: Packed<'UserDetailed'>; - meUpdated: Packed<'UserDetailed'>; + followed: Packed<'UserLite'>; + unfollow: Packed<'UserDetailedNotMe'>; + meUpdated: Packed<'MeDetailed'>; pageEvent: { pageId: MiPage['id']; event: string; var: any; userId: MiUser['id']; - user: Packed<'User'>; + user: Packed<'UserDetailed'>; }; urlUploadFinished: { marker?: string | null; @@ -92,7 +92,7 @@ export interface MainEventTypes { }; driveFileCreated: Packed<'DriveFile'>; readAntenna: MiAntenna; - receiveFollowRequest: Packed<'User'>; + receiveFollowRequest: Packed<'UserLite'>; announcementCreated: { announcement: Packed<'Announcement'>; }; @@ -140,8 +140,8 @@ type NoteStreamEventTypes = { }; export interface UserListEventTypes { - userAdded: Packed<'User'>; - userRemoved: Packed<'User'>; + userAdded: Packed<'UserLite'>; + userRemoved: Packed<'UserLite'>; } export interface AntennaEventTypes { diff --git a/packages/backend/src/core/UserBlockingService.ts b/packages/backend/src/core/UserBlockingService.ts index 39b19325c3..c267849908 100644 --- a/packages/backend/src/core/UserBlockingService.ts +++ b/packages/backend/src/core/UserBlockingService.ts @@ -109,13 +109,13 @@ export class UserBlockingService implements OnModuleInit { if (this.userEntityService.isLocalUser(followee)) { this.userEntityService.pack(followee, followee, { - detail: true, + schema: 'MeDetailed', }).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed)); } if (this.userEntityService.isLocalUser(follower) && !silent) { this.userEntityService.pack(followee, follower, { - detail: true, + schema: 'UserDetailedNotMe', }).then(async packed => { this.globalEventService.publishMainStream(follower.id, 'unfollow', packed); diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index d600ffb9d9..93e9fbbd70 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -293,9 +293,9 @@ export class UserFollowingService implements OnModuleInit { if (this.userEntityService.isLocalUser(follower) && !silent) { // Publish follow event this.userEntityService.pack(followee.id, follower, { - detail: true, + schema: 'UserDetailedNotMe', }).then(async packed => { - this.globalEventService.publishMainStream(follower.id, 'follow', packed as Packed<'UserDetailedNotMe'>); + this.globalEventService.publishMainStream(follower.id, 'follow', packed); const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow')); for (const webhook of webhooks) { @@ -360,7 +360,7 @@ export class UserFollowingService implements OnModuleInit { if (!silent && this.userEntityService.isLocalUser(follower)) { // Publish unfollow event this.userEntityService.pack(followee.id, follower, { - detail: true, + schema: 'UserDetailedNotMe', }).then(async packed => { this.globalEventService.publishMainStream(follower.id, 'unfollow', packed); @@ -500,7 +500,7 @@ export class UserFollowingService implements OnModuleInit { this.userEntityService.pack(follower.id, followee).then(packed => this.globalEventService.publishMainStream(followee.id, 'receiveFollowRequest', packed)); this.userEntityService.pack(followee.id, followee, { - detail: true, + schema: 'MeDetailed', }).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed)); // 通知を作成 @@ -548,7 +548,7 @@ export class UserFollowingService implements OnModuleInit { }); this.userEntityService.pack(followee.id, followee, { - detail: true, + schema: 'MeDetailed', }).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed)); } @@ -576,7 +576,7 @@ export class UserFollowingService implements OnModuleInit { } this.userEntityService.pack(followee.id, followee, { - detail: true, + schema: 'MeDetailed', }).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed)); } @@ -696,7 +696,7 @@ export class UserFollowingService implements OnModuleInit { @bindThis private async publishUnfollow(followee: Both, follower: Local): Promise { const packedFollowee = await this.userEntityService.pack(followee.id, follower, { - detail: true, + schema: 'UserDetailedNotMe', }); this.globalEventService.publishMainStream(follower.id, 'unfollow', packedFollowee); diff --git a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts index 97de891ece..e7814161b8 100644 --- a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts +++ b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts @@ -38,13 +38,13 @@ export class AbuseUserReportEntityService { targetUserId: report.targetUserId, assigneeId: report.assigneeId, reporter: this.userEntityService.pack(report.reporter ?? report.reporterId, null, { - detail: true, + schema: 'UserDetailedNotMe', }), targetUser: this.userEntityService.pack(report.targetUser ?? report.targetUserId, null, { - detail: true, + schema: 'UserDetailedNotMe', }), assignee: report.assigneeId ? this.userEntityService.pack(report.assignee ?? report.assigneeId, null, { - detail: true, + schema: 'UserDetailedNotMe', }) : null, forwarded: report.forwarded, }); diff --git a/packages/backend/src/core/entities/BlockingEntityService.ts b/packages/backend/src/core/entities/BlockingEntityService.ts index b4760346b7..f5abf67322 100644 --- a/packages/backend/src/core/entities/BlockingEntityService.ts +++ b/packages/backend/src/core/entities/BlockingEntityService.ts @@ -37,7 +37,7 @@ export class BlockingEntityService { createdAt: this.idService.parse(blocking.id).date.toISOString(), blockeeId: blocking.blockeeId, blockee: this.userEntityService.pack(blocking.blockeeId, me, { - detail: true, + schema: 'UserDetailedNotMe', }), }); } diff --git a/packages/backend/src/core/entities/FlashEntityService.ts b/packages/backend/src/core/entities/FlashEntityService.ts index dc335d9975..70faa2b380 100644 --- a/packages/backend/src/core/entities/FlashEntityService.ts +++ b/packages/backend/src/core/entities/FlashEntityService.ts @@ -42,7 +42,7 @@ export class FlashEntityService { createdAt: this.idService.parse(flash.id).date.toISOString(), updatedAt: flash.updatedAt.toISOString(), userId: flash.userId, - user: this.userEntityService.pack(flash.user ?? flash.userId, me), // { detail: true } すると無限ループするので注意 + user: this.userEntityService.pack(flash.user ?? flash.userId, me), // { schema: 'UserDetailed' } すると無限ループするので注意 title: flash.title, summary: flash.summary, script: flash.script, diff --git a/packages/backend/src/core/entities/FollowingEntityService.ts b/packages/backend/src/core/entities/FollowingEntityService.ts index 52aa979677..f9bc9fa1ab 100644 --- a/packages/backend/src/core/entities/FollowingEntityService.ts +++ b/packages/backend/src/core/entities/FollowingEntityService.ts @@ -89,10 +89,10 @@ export class FollowingEntityService { followeeId: following.followeeId, followerId: following.followerId, followee: opts.populateFollowee ? this.userEntityService.pack(following.followee ?? following.followeeId, me, { - detail: true, + schema: 'UserDetailedNotMe', }) : undefined, follower: opts.populateFollower ? this.userEntityService.pack(following.follower ?? following.followerId, me, { - detail: true, + schema: 'UserDetailedNotMe', }) : undefined, }); } diff --git a/packages/backend/src/core/entities/ModerationLogEntityService.ts b/packages/backend/src/core/entities/ModerationLogEntityService.ts index 6729ca2671..3add9dbc74 100644 --- a/packages/backend/src/core/entities/ModerationLogEntityService.ts +++ b/packages/backend/src/core/entities/ModerationLogEntityService.ts @@ -37,7 +37,7 @@ export class ModerationLogEntityService { info: log.info, userId: log.userId, user: this.userEntityService.pack(log.user ?? log.userId, null, { - detail: true, + schema: 'UserDetailedNotMe', }), }); } diff --git a/packages/backend/src/core/entities/MutingEntityService.ts b/packages/backend/src/core/entities/MutingEntityService.ts index 9d672169ba..5326955126 100644 --- a/packages/backend/src/core/entities/MutingEntityService.ts +++ b/packages/backend/src/core/entities/MutingEntityService.ts @@ -39,7 +39,7 @@ export class MutingEntityService { expiresAt: muting.expiresAt ? muting.expiresAt.toISOString() : null, muteeId: muting.muteeId, mutee: this.userEntityService.pack(muting.muteeId, me, { - detail: true, + schema: 'UserDetailedNotMe', }), }); } diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 03cd58917b..a095a5daf7 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -324,9 +324,7 @@ export class NoteEntityService implements OnModuleInit { id: note.id, createdAt: this.idService.parse(note.id).date.toISOString(), userId: note.userId, - user: this.userEntityService.pack(note.user ?? note.userId, me, { - detail: false, - }), + user: this.userEntityService.pack(note.user ?? note.userId, me), text: text, cw: note.cw, visibility: note.visibility, diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index 704081ed00..a620acc2dc 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -62,7 +62,7 @@ export class NotificationEntityService implements OnModuleInit { }, hint?: { packedNotes: Map>; - packedUsers: Map>; + packedUsers: Map>; }, ): Promise> { const notification = src; @@ -76,9 +76,7 @@ export class NotificationEntityService implements OnModuleInit { const userIfNeed = 'notifierId' in notification ? ( hint?.packedUsers != null ? hint.packedUsers.get(notification.notifierId) - : this.userEntityService.pack(notification.notifierId, { id: meId }, { - detail: false, - }) + : this.userEntityService.pack(notification.notifierId, { id: meId }) ) : undefined; const role = notification.type === 'roleAssigned' ? await this.roleEntityService.pack(notification.roleId) : undefined; @@ -131,9 +129,7 @@ export class NotificationEntityService implements OnModuleInit { const users = userIds.length > 0 ? await this.usersRepository.find({ where: { id: In(userIds) }, }) : []; - const packedUsersArray = await this.userEntityService.packMany(users, { id: meId }, { - detail: false, - }); + const packedUsersArray = await this.userEntityService.packMany(users, { id: meId }); const packedUsers = new Map(packedUsersArray.map(p => [p.id, p])); // 既に解決されたフォローリクエストの通知を除外 @@ -161,7 +157,7 @@ export class NotificationEntityService implements OnModuleInit { }, hint?: { packedNotes: Map>; - packedUsers: Map>; + packedUsers: Map>; }, ): Promise> { const notification = src; @@ -175,18 +171,14 @@ export class NotificationEntityService implements OnModuleInit { const userIfNeed = 'notifierId' in notification ? ( hint?.packedUsers != null ? hint.packedUsers.get(notification.notifierId) - : this.userEntityService.pack(notification.notifierId, { id: meId }, { - detail: false, - }) + : this.userEntityService.pack(notification.notifierId, { id: meId }) ) : undefined; if (notification.type === 'reaction:grouped') { const reactions = await Promise.all(notification.reactions.map(async reaction => { const user = hint?.packedUsers != null ? hint.packedUsers.get(reaction.userId)! - : await this.userEntityService.pack(reaction.userId, { id: meId }, { - detail: false, - }); + : await this.userEntityService.pack(reaction.userId, { id: meId }); return { user, reaction: reaction.reaction, @@ -206,9 +198,7 @@ export class NotificationEntityService implements OnModuleInit { return packedUser; } - return this.userEntityService.pack(userId, { id: meId }, { - detail: false, - }); + return this.userEntityService.pack(userId, { id: meId }); })); return await awaitAll({ id: notification.id, @@ -275,9 +265,7 @@ export class NotificationEntityService implements OnModuleInit { const users = userIds.length > 0 ? await this.usersRepository.find({ where: { id: In(userIds) }, }) : []; - const packedUsersArray = await this.userEntityService.packMany(users, { id: meId }, { - detail: false, - }); + const packedUsersArray = await this.userEntityService.packMany(users, { id: meId }); const packedUsers = new Map(packedUsersArray.map(p => [p.id, p])); // 既に解決されたフォローリクエストの通知を除外 diff --git a/packages/backend/src/core/entities/PageEntityService.ts b/packages/backend/src/core/entities/PageEntityService.ts index f39ef949db..bc26362aba 100644 --- a/packages/backend/src/core/entities/PageEntityService.ts +++ b/packages/backend/src/core/entities/PageEntityService.ts @@ -90,7 +90,7 @@ export class PageEntityService { createdAt: this.idService.parse(page.id).date.toISOString(), updatedAt: page.updatedAt.toISOString(), userId: page.userId, - user: this.userEntityService.pack(page.user ?? page.userId, me), // { detail: true } すると無限ループするので注意 + user: this.userEntityService.pack(page.user ?? page.userId, me), // { schema: 'UserDetailed' } すると無限ループするので注意 content: page.content, variables: page.variables, title: page.title, diff --git a/packages/backend/src/core/entities/RenoteMutingEntityService.ts b/packages/backend/src/core/entities/RenoteMutingEntityService.ts index 3f9dc9180a..5ad28f2e6a 100644 --- a/packages/backend/src/core/entities/RenoteMutingEntityService.ts +++ b/packages/backend/src/core/entities/RenoteMutingEntityService.ts @@ -38,7 +38,7 @@ export class RenoteMutingEntityService { createdAt: this.idService.parse(muting.id).date.toISOString(), muteeId: muting.muteeId, mutee: this.userEntityService.pack(muting.muteeId, me, { - detail: true, + schema: 'UserDetailedNotMe', }), }); } diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index ef815a388a..a09369409b 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -30,14 +30,6 @@ import type { NoteEntityService } from './NoteEntityService.js'; import type { DriveFileEntityService } from './DriveFileEntityService.js'; import type { PageEntityService } from './PageEntityService.js'; -type IsUserDetailed = Detailed extends true ? Packed<'UserDetailed'> : Packed<'UserLite'>; -type IsMeAndIsUserDetailed = - Detailed extends true ? - ExpectsMe extends true ? Packed<'MeDetailed'> : - ExpectsMe extends false ? Packed<'UserDetailedNotMe'> : - Packed<'UserDetailed'> : - Packed<'UserLite'>; - const Ajv = _Ajv.default; const ajv = new Ajv(); @@ -303,33 +295,34 @@ export class UserEntityService implements OnModuleInit { return `${this.config.url}/users/${userId}`; } - public async pack( + public async pack( src: MiUser['id'] | MiUser, me?: { id: MiUser['id']; } | null | undefined, options?: { - detail?: D, + schema?: S, includeSecrets?: boolean, userProfile?: MiUserProfile, }, - ): Promise> { + ): Promise> { const opts = Object.assign({ - detail: false, + schema: 'UserLite', includeSecrets: false, }, options); const user = typeof src === 'object' ? src : await this.usersRepository.findOneByOrFail({ id: src }); + const isDetailed = opts.schema !== 'UserLite'; const meId = me ? me.id : null; const isMe = meId === user.id; const iAmModerator = me ? await this.roleService.isModerator(me as MiUser) : false; - const relation = meId && !isMe && opts.detail ? await this.getRelation(meId, user.id) : null; - const pins = opts.detail ? await this.userNotePiningsRepository.createQueryBuilder('pin') + const relation = meId && !isMe && isDetailed ? await this.getRelation(meId, user.id) : null; + const pins = isDetailed ? await this.userNotePiningsRepository.createQueryBuilder('pin') .where('pin.userId = :userId', { userId: user.id }) .innerJoinAndSelect('pin.note', 'note') .orderBy('pin.id', 'DESC') .getMany() : []; - const profile = opts.detail ? (opts.userProfile ?? await this.userProfilesRepository.findOneByOrFail({ userId: user.id })) : null; + const profile = isDetailed ? (opts.userProfile ?? await this.userProfilesRepository.findOneByOrFail({ userId: user.id })) : null; const followingCount = profile == null ? null : (profile.followingVisibility === 'public') || isMe ? user.followingCount : @@ -341,15 +334,15 @@ export class UserEntityService implements OnModuleInit { (profile.followersVisibility === 'followers') && (relation && relation.isFollowing) ? user.followersCount : null; - const isModerator = isMe && opts.detail ? this.roleService.isModerator(user) : null; - const isAdmin = isMe && opts.detail ? this.roleService.isAdministrator(user) : null; - const unreadAnnouncements = isMe && opts.detail ? + const isModerator = isMe && isDetailed ? this.roleService.isModerator(user) : null; + const isAdmin = isMe && isDetailed ? this.roleService.isAdministrator(user) : null; + const unreadAnnouncements = isMe && isDetailed ? (await this.announcementService.getUnreadAnnouncements(user)).map((announcement) => ({ createdAt: this.idService.parse(announcement.id).date.toISOString(), ...announcement, })) : null; - const notificationsInfo = isMe && opts.detail ? await this.getNotificationsInfo(user.id) : null; + const notificationsInfo = isMe && isDetailed ? await this.getNotificationsInfo(user.id) : null; const packed = { id: user.id, @@ -385,7 +378,7 @@ export class UserEntityService implements OnModuleInit { displayOrder: r.displayOrder, }))) : undefined, - ...(opts.detail ? { + ...(isDetailed ? { url: profile!.url, uri: user.uri, movedTo: user.movedToUri ? this.apPersonService.resolvePerson(user.movedToUri).then(user => user.id).catch(() => null) : null, @@ -443,7 +436,7 @@ export class UserEntityService implements OnModuleInit { moderationNote: iAmModerator ? (profile!.moderationNote ?? '') : undefined, } : {}), - ...(opts.detail && isMe ? { + ...(isDetailed && isMe ? { avatarId: user.avatarId, bannerId: user.bannerId, isModerator: isModerator, @@ -515,19 +508,19 @@ export class UserEntityService implements OnModuleInit { notify: relation.following?.notify ?? 'none', withReplies: relation.following?.withReplies ?? false, } : {}), - } as Promiseable> as Promiseable>; + } as Promiseable>; return await awaitAll(packed); } - public packMany( + public packMany( users: (MiUser['id'] | MiUser)[], me?: { id: MiUser['id'] } | null | undefined, options?: { - detail?: D, + schema?: S, includeSecrets?: boolean, }, - ): Promise[]> { + ): Promise[]> { return Promise.all(users.map(u => this.pack(u, me, options))); } } diff --git a/packages/backend/src/models/json-schema/blocking.ts b/packages/backend/src/models/json-schema/blocking.ts index 0b58f1f8d7..1b3227d455 100644 --- a/packages/backend/src/models/json-schema/blocking.ts +++ b/packages/backend/src/models/json-schema/blocking.ts @@ -25,7 +25,7 @@ export const packedBlockingSchema = { blockee: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailed', + ref: 'UserDetailedNotMe', }, }, } as const; diff --git a/packages/backend/src/models/json-schema/following.ts b/packages/backend/src/models/json-schema/following.ts index e92cff20a1..dd3234ee5a 100644 --- a/packages/backend/src/models/json-schema/following.ts +++ b/packages/backend/src/models/json-schema/following.ts @@ -30,12 +30,12 @@ export const packedFollowingSchema = { followee: { type: 'object', optional: true, nullable: false, - ref: 'UserDetailed', + ref: 'UserDetailedNotMe', }, follower: { type: 'object', optional: true, nullable: false, - ref: 'UserDetailed', + ref: 'UserDetailedNotMe', }, }, } as const; diff --git a/packages/backend/src/models/json-schema/muting.ts b/packages/backend/src/models/json-schema/muting.ts index dde9dc0288..c3d0bb603c 100644 --- a/packages/backend/src/models/json-schema/muting.ts +++ b/packages/backend/src/models/json-schema/muting.ts @@ -30,7 +30,7 @@ export const packedMutingSchema = { mutee: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailed', + ref: 'UserDetailedNotMe', }, }, } as const; diff --git a/packages/backend/src/models/json-schema/renote-muting.ts b/packages/backend/src/models/json-schema/renote-muting.ts index feed1ceb09..769b33f515 100644 --- a/packages/backend/src/models/json-schema/renote-muting.ts +++ b/packages/backend/src/models/json-schema/renote-muting.ts @@ -25,7 +25,7 @@ export const packedRenoteMutingSchema = { mutee: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailed', + ref: 'UserDetailedNotMe', }, }, } as const; diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index 7447513a93..ca51755317 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -685,13 +685,5 @@ export const packedUserSchema = { type: 'object', ref: 'UserDetailed', }, - { - type: 'object', - ref: 'UserDetailedNotMe', - }, - { - type: 'object', - ref: 'MeDetailed', - }, ], } as const; diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index 632a7692cd..0b65c1ea74 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -204,7 +204,7 @@ export class ServerService implements OnApplicationShutdown { }); this.globalEventService.publishMainStream(profile.userId, 'meUpdated', await this.userEntityService.pack(profile.userId, { id: profile.userId }, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); diff --git a/packages/backend/src/server/api/ApiServerService.ts b/packages/backend/src/server/api/ApiServerService.ts index 1758c03aca..386e593636 100644 --- a/packages/backend/src/server/api/ApiServerService.ts +++ b/packages/backend/src/server/api/ApiServerService.ts @@ -157,7 +157,7 @@ export class ApiServerService { return { ok: true, token: token.token, - user: await this.userEntityService.pack(token.userId, null, { detail: true }), + user: await this.userEntityService.pack(token.userId, null, { schema: 'UserDetailedNotMe' }), }; } else { return { diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index 6b4d9d9f70..95016cdba6 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -213,7 +213,7 @@ export class SignupApiService { }); const res = await this.userEntityService.pack(account, account, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, }); diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts index 3484d6707a..4ffefa05b7 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts @@ -62,17 +62,17 @@ export const meta = { reporter: { type: 'object', nullable: false, optional: false, - ref: 'User', + ref: 'UserDetailedNotMe', }, targetUser: { type: 'object', nullable: false, optional: false, - ref: 'User', + ref: 'UserDetailedNotMe', }, assignee: { type: 'object', nullable: true, optional: true, - ref: 'User', + ref: 'UserDetailedNotMe', }, }, }, diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts index f54d567fff..b18a7e0e41 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts @@ -11,6 +11,7 @@ import { SignupService } from '@/core/SignupService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { localUsernameSchema, passwordSchema } from '@/models/User.js'; import { DI } from '@/di-symbols.js'; +import { Packed } from '@/misc/json-schema.js'; export const meta = { tags: ['admin'], @@ -18,7 +19,7 @@ export const meta = { res: { type: 'object', optional: false, nullable: false, - ref: 'User', + ref: 'MeDetailed', properties: { token: { type: 'string', @@ -60,11 +61,11 @@ export default class extends Endpoint { // eslint- }); const res = await this.userEntityService.pack(account, account, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, - }); + }) as Packed<'MeDetailed'> & { token: string }; - (res as any).token = secret; + res.token = secret; return res; }); diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/find-by-email.ts b/packages/backend/src/server/api/endpoints/admin/accounts/find-by-email.ts index 93673453d6..80b198eb80 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/find-by-email.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/find-by-email.ts @@ -27,7 +27,7 @@ export const meta = { res: { type: 'object', optional: false, nullable: false, - ref: 'User', + ref: 'UserDetailedNotMe', }, } as const; @@ -58,7 +58,7 @@ export default class extends Endpoint { // eslint- } const res = await this.userEntityService.pack(profile.user!, null, { - detail: true, + schema: 'UserDetailedNotMe', }); return res; diff --git a/packages/backend/src/server/api/endpoints/admin/roles/users.ts b/packages/backend/src/server/api/endpoints/admin/roles/users.ts index 66f4d9d26b..1e05685991 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/users.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/users.ts @@ -40,7 +40,7 @@ export const meta = { }, required: ['id', 'createdAt', 'user'], }, - } + }, } as const; export const paramDef = { @@ -92,7 +92,7 @@ export default class extends Endpoint { // eslint- return await Promise.all(assigns.map(async assign => ({ id: assign.id, createdAt: this.idService.parse(assign.id).date.toISOString(), - user: await this.userEntityService.pack(assign.user!, me, { detail: true }), + user: await this.userEntityService.pack(assign.user!, me, { schema: 'UserDetailed' }), expiresAt: assign.expiresAt?.toISOString() ?? null, }))); }); diff --git a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts index f3601be9bb..51b5a02600 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts @@ -50,7 +50,7 @@ export const meta = { user: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailed', + ref: 'UserDetailedNotMe', }, }, }, diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index 1d31e5e80f..80611266df 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -114,7 +114,7 @@ export default class extends Endpoint { // eslint- const users = await query.getMany(); - return await this.userEntityService.packMany(users, me, { detail: true }); + return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index 7e5c7a917c..4c1236eaa1 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -148,7 +148,7 @@ export default class extends Endpoint { // eslint- if (user != null) { return { type: 'User', - object: await this.userEntityService.pack(user, me, { detail: true }), + object: await this.userEntityService.pack(user, me, { schema: 'UserDetailedNotMe' }), }; } else if (note != null) { try { diff --git a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts index ffddda090b..eeb580cead 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts @@ -112,7 +112,7 @@ export default class extends Endpoint { // eslint- return { accessToken: accessToken.token, user: await this.userEntityService.pack(session.userId, null, { - detail: true, + schema: 'UserDetailedNotMe', }), }; }); diff --git a/packages/backend/src/server/api/endpoints/blocking/create.ts b/packages/backend/src/server/api/endpoints/blocking/create.ts index 3c7d7ac8cd..1dc4563180 100644 --- a/packages/backend/src/server/api/endpoints/blocking/create.ts +++ b/packages/backend/src/server/api/endpoints/blocking/create.ts @@ -102,7 +102,7 @@ export default class extends Endpoint { // eslint- await this.userBlockingService.block(blocker, blockee); return await this.userEntityService.pack(blockee.id, blocker, { - detail: true, + schema: 'UserDetailedNotMe', }); }); } diff --git a/packages/backend/src/server/api/endpoints/blocking/delete.ts b/packages/backend/src/server/api/endpoints/blocking/delete.ts index 0ce334d559..a6e6bcb5b3 100644 --- a/packages/backend/src/server/api/endpoints/blocking/delete.ts +++ b/packages/backend/src/server/api/endpoints/blocking/delete.ts @@ -103,7 +103,7 @@ export default class extends Endpoint { // eslint- await this.userBlockingService.unblock(blocker, blockee); return await this.userEntityService.pack(blockee.id, blocker, { - detail: true, + schema: 'UserDetailedNotMe', }); }); } diff --git a/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts b/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts index 9c057760ca..731bcc5b65 100644 --- a/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts +++ b/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts @@ -61,7 +61,7 @@ export default class extends Endpoint { // eslint- relations: ['user'], }); - const users = await this.userEntityService.packMany(records.map(r => r.user!), null, { detail: false }); + const users = await this.userEntityService.packMany(records.map(r => r.user!), null); return records.map(r => ({ id: r.id, diff --git a/packages/backend/src/server/api/endpoints/federation/users.ts b/packages/backend/src/server/api/endpoints/federation/users.ts index d97171865a..df8b66ab44 100644 --- a/packages/backend/src/server/api/endpoints/federation/users.ts +++ b/packages/backend/src/server/api/endpoints/federation/users.ts @@ -54,7 +54,7 @@ export default class extends Endpoint { // eslint- .limit(ps.limit) .getMany(); - return await this.userEntityService.packMany(users, me, { detail: true }); + return await this.userEntityService.packMany(users, me, { schema: 'UserDetailedNotMe' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/hashtags/users.ts b/packages/backend/src/server/api/endpoints/hashtags/users.ts index 8302d2380f..5071dd22b7 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/users.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/users.ts @@ -76,7 +76,7 @@ export default class extends Endpoint { // eslint- const users = await query.limit(ps.limit).getMany(); - return await this.userEntityService.packMany(users, me, { detail: true }); + return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/i.ts b/packages/backend/src/server/api/endpoints/i.ts index c24e049180..c613794589 100644 --- a/packages/backend/src/server/api/endpoints/i.ts +++ b/packages/backend/src/server/api/endpoints/i.ts @@ -71,8 +71,8 @@ export default class extends Endpoint { // eslint- userProfile.loggedInDates = [...userProfile.loggedInDates, today]; } - return await this.userEntityService.pack(userProfile.user!, userProfile.user!, { - detail: true, + return await this.userEntityService.pack(userProfile.user!, userProfile.user!, { + schema: 'MeDetailed', includeSecrets: isSecure, userProfile, }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/done.ts b/packages/backend/src/server/api/endpoints/i/2fa/done.ts index 9f8e2894b8..7aaf3982d1 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/done.ts @@ -64,7 +64,7 @@ export default class extends Endpoint { // eslint- // Publish meUpdated event this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts index a7be47fd0f..a88a1e50de 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts @@ -111,7 +111,7 @@ export default class extends Endpoint { // Publish meUpdated event this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts index 2ed701014d..b68f23bf8a 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts @@ -74,7 +74,7 @@ export default class extends Endpoint { // eslint- // Publish meUpdated event this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts index da8ac98556..74a9cd77f0 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts @@ -97,7 +97,7 @@ export default class extends Endpoint { // eslint- // Publish meUpdated event this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts index 338f12c5cd..6508c8b4e7 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts @@ -76,7 +76,7 @@ export default class extends Endpoint { // eslint- // Publish meUpdated event this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts index 1a140c1d05..8d894e8f85 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts @@ -69,7 +69,7 @@ export default class extends Endpoint { // eslint- // Publish meUpdated event this.globalEventService.publishMainStream(me.id, 'meUpdated', await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, })); diff --git a/packages/backend/src/server/api/endpoints/i/pin.ts b/packages/backend/src/server/api/endpoints/i/pin.ts index c89cdfa3a4..71182cc29a 100644 --- a/packages/backend/src/server/api/endpoints/i/pin.ts +++ b/packages/backend/src/server/api/endpoints/i/pin.ts @@ -66,8 +66,8 @@ export default class extends Endpoint { // eslint- throw err; }); - return await this.userEntityService.pack(me.id, me, { - detail: true, + return await this.userEntityService.pack(me.id, me, { + schema: 'MeDetailed', }); }); } diff --git a/packages/backend/src/server/api/endpoints/i/unpin.ts b/packages/backend/src/server/api/endpoints/i/unpin.ts index b59c0e954f..1e5f66f4a8 100644 --- a/packages/backend/src/server/api/endpoints/i/unpin.ts +++ b/packages/backend/src/server/api/endpoints/i/unpin.ts @@ -51,8 +51,8 @@ export default class extends Endpoint { // eslint- throw err; }); - return await this.userEntityService.pack(me.id, me, { - detail: true, + return await this.userEntityService.pack(me.id, me, { + schema: 'MeDetailed', }); }); } diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts index 52977f5a07..cc3ec11708 100644 --- a/packages/backend/src/server/api/endpoints/i/update-email.ts +++ b/packages/backend/src/server/api/endpoints/i/update-email.ts @@ -43,7 +43,7 @@ export const meta = { res: { type: 'object', - ref: 'UserDetailed', + ref: 'MeDetailed', }, } as const; @@ -106,7 +106,7 @@ export default class extends Endpoint { // eslint- }); const iObj = await this.userEntityService.pack(me.id, me, { - detail: true, + schema: 'MeDetailed', includeSecrets: true, }); diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index eed3082258..584321557b 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -446,8 +446,8 @@ export default class extends Endpoint { // eslint- verifiedLinks: [], }); - const iObj = await this.userEntityService.pack(user.id, user, { - detail: true, + const iObj = await this.userEntityService.pack(user.id, user, { + schema: 'MeDetailed', includeSecrets: isSecure, }); diff --git a/packages/backend/src/server/api/endpoints/page-push.ts b/packages/backend/src/server/api/endpoints/page-push.ts index 0a68516586..49fcaf061b 100644 --- a/packages/backend/src/server/api/endpoints/page-push.ts +++ b/packages/backend/src/server/api/endpoints/page-push.ts @@ -55,7 +55,7 @@ export default class extends Endpoint { // eslint- var: ps.var, userId: me.id, user: await this.userEntityService.pack(me.id, { id: page.userId }, { - detail: true, + schema: 'UserDetailed', }), }); }); diff --git a/packages/backend/src/server/api/endpoints/pinned-users.ts b/packages/backend/src/server/api/endpoints/pinned-users.ts index 390042c815..415633e8b6 100644 --- a/packages/backend/src/server/api/endpoints/pinned-users.ts +++ b/packages/backend/src/server/api/endpoints/pinned-users.ts @@ -52,7 +52,7 @@ export default class extends Endpoint { // eslint- host: acct.host ?? IsNull(), }))); - return await this.userEntityService.packMany(users.filter(x => x !== null) as MiUser[], me, { detail: true }); + return await this.userEntityService.packMany(users.filter(x => x !== null) as MiUser[], me, { schema: 'UserDetailed' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/roles/users.ts b/packages/backend/src/server/api/endpoints/roles/users.ts index d304d075b2..2e43af5c52 100644 --- a/packages/backend/src/server/api/endpoints/roles/users.ts +++ b/packages/backend/src/server/api/endpoints/roles/users.ts @@ -33,11 +33,11 @@ export const meta = { properties: { id: { type: 'string', - format: 'misskey:id' + format: 'misskey:id', }, user: { type: 'object', - ref: 'User' + ref: 'UserDetailed', }, }, required: ['id', 'user'], @@ -94,7 +94,7 @@ export default class extends Endpoint { // eslint- return await Promise.all(assigns.map(async assign => ({ id: assign.id, - user: await this.userEntityService.pack(assign.user!, me, { detail: true }), + user: await this.userEntityService.pack(assign.user!, me, { schema: 'UserDetailed' }), }))); }); } diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index 8dc5841314..b886dd4a60 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -89,7 +89,7 @@ export default class extends Endpoint { // eslint- const users = await query.getMany(); - return await this.userEntityService.packMany(users, me, { detail: true }); + return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts index d6fb65cecb..6c04a06cbc 100644 --- a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts +++ b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts @@ -122,7 +122,7 @@ export default class extends Endpoint { // eslint- // Make replies object (includes weights) const repliesObj = await Promise.all(topRepliedUsers.map(async (user) => ({ - user: await this.userEntityService.pack(user, me, { detail: true }), + user: await this.userEntityService.pack(user, me, { schema: 'UserDetailed' }), weight: repliedUsers[user] / peak, }))); diff --git a/packages/backend/src/server/api/endpoints/users/lists/get-memberships.ts b/packages/backend/src/server/api/endpoints/users/lists/get-memberships.ts index 985141515e..1fd3232de6 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/get-memberships.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/get-memberships.ts @@ -46,7 +46,7 @@ export const meta = { }, user: { type: 'object', - ref: 'User', + ref: 'UserLite', }, withReplies: { type: 'boolean', diff --git a/packages/backend/src/server/api/endpoints/users/recommendation.ts b/packages/backend/src/server/api/endpoints/users/recommendation.ts index 1b30e99b15..c73495e3c7 100644 --- a/packages/backend/src/server/api/endpoints/users/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/users/recommendation.ts @@ -76,7 +76,7 @@ export default class extends Endpoint { // eslint- const users = await query.limit(ps.limit).offset(ps.offset).getMany(); - return await this.userEntityService.packMany(users, me, { detail: true }); + return await this.userEntityService.packMany(users, me, { schema: 'UserDetailed' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts index 4bf25d9fbb..7d36f6f932 100644 --- a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts +++ b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts @@ -131,7 +131,7 @@ export default class extends Endpoint { // eslint- .getMany(); } - return await this.userEntityService.packMany(users, me, { detail: !!ps.detail }); + return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index 32b5c12372..bc86136592 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -141,7 +141,7 @@ export default class extends Endpoint { // eslint- } } - return await this.userEntityService.packMany(users, me, { detail: ps.detail }); + return await this.userEntityService.packMany(users, me, { schema: ps.detail ? 'UserDetailed' : 'UserLite' }); }); } } diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts index 389497301d..4cf3858494 100644 --- a/packages/backend/src/server/api/endpoints/users/show.ts +++ b/packages/backend/src/server/api/endpoints/users/show.ts @@ -116,7 +116,7 @@ export default class extends Endpoint { // eslint- } return await Promise.all(_users.map(u => this.userEntityService.pack(u, me, { - detail: true, + schema: 'UserDetailed', }))); } else { // Lookup user @@ -146,7 +146,7 @@ export default class extends Endpoint { // eslint- } return await this.userEntityService.pack(user, me, { - detail: true, + schema: 'UserDetailed', }); } }); diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 860d3629d6..3592153f9e 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -2235,7 +2235,7 @@ type ModerationLog = { id: ID; createdAt: DateString; userId: User['id']; - user: UserDetailed | null; + user: UserDetailedNotMe | null; } & ({ type: 'updateServerSettings'; info: ModerationLogPayloads['updateServerSettings']; diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index 86cc45f980..0f1223d1f8 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -1,6 +1,6 @@ /* - * version: 2024.2.0-beta.7 - * generatedAt: 2024-01-30T11:53:29.839Z + * version: 2024.2.0-beta.8 + * generatedAt: 2024-01-31T01:46:47.964Z */ import type { SwitchCaseResponseType } from '../api.js'; diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index c79699513b..d319fe7978 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -1,6 +1,6 @@ /* - * version: 2024.2.0-beta.7 - * generatedAt: 2024-01-30T11:53:29.837Z + * version: 2024.2.0-beta.8 + * generatedAt: 2024-01-31T01:46:47.962Z */ import type { diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index d1f1147556..ea2ca3948a 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -1,6 +1,6 @@ /* - * version: 2024.2.0-beta.7 - * generatedAt: 2024-01-30T11:53:29.836Z + * version: 2024.2.0-beta.8 + * generatedAt: 2024-01-31T01:46:47.961Z */ import { operations } from './types.js'; diff --git a/packages/misskey-js/src/autogen/models.ts b/packages/misskey-js/src/autogen/models.ts index ac5910acf8..8ab5eeac9f 100644 --- a/packages/misskey-js/src/autogen/models.ts +++ b/packages/misskey-js/src/autogen/models.ts @@ -1,6 +1,6 @@ /* - * version: 2024.2.0-beta.7 - * generatedAt: 2024-01-30T11:53:29.835Z + * version: 2024.2.0-beta.8 + * generatedAt: 2024-01-31T01:46:47.959Z */ import { components } from './types.js'; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 0c4f931fbd..1731b57003 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -2,8 +2,8 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ /* - * version: 2024.2.0-beta.7 - * generatedAt: 2024-01-30T11:53:29.755Z + * version: 2024.2.0-beta.8 + * generatedAt: 2024-01-31T01:46:47.878Z */ /** @@ -3761,7 +3761,7 @@ export type components = { UserDetailedNotMe: components['schemas']['UserLite'] & components['schemas']['UserDetailedNotMeOnly']; MeDetailed: components['schemas']['UserLite'] & components['schemas']['UserDetailedNotMeOnly'] & components['schemas']['MeDetailedOnly']; UserDetailed: components['schemas']['UserDetailedNotMe'] | components['schemas']['MeDetailed']; - User: components['schemas']['UserLite'] | components['schemas']['UserDetailed'] | components['schemas']['UserDetailedNotMe'] | components['schemas']['MeDetailed']; + User: components['schemas']['UserLite'] | components['schemas']['UserDetailed']; UserList: { /** * Format: id @@ -4164,8 +4164,8 @@ export type components = { followeeId: string; /** Format: id */ followerId: string; - followee?: components['schemas']['UserDetailed']; - follower?: components['schemas']['UserDetailed']; + followee?: components['schemas']['UserDetailedNotMe']; + follower?: components['schemas']['UserDetailedNotMe']; }; Muting: { /** @@ -4179,7 +4179,7 @@ export type components = { expiresAt: string | null; /** Format: id */ muteeId: string; - mutee: components['schemas']['UserDetailed']; + mutee: components['schemas']['UserDetailedNotMe']; }; RenoteMuting: { /** @@ -4191,7 +4191,7 @@ export type components = { createdAt: string; /** Format: id */ muteeId: string; - mutee: components['schemas']['UserDetailed']; + mutee: components['schemas']['UserDetailedNotMe']; }; Blocking: { /** @@ -4203,7 +4203,7 @@ export type components = { createdAt: string; /** Format: id */ blockeeId: string; - blockee: components['schemas']['UserDetailed']; + blockee: components['schemas']['UserDetailedNotMe']; }; Hashtag: { /** @example misskey */ @@ -4823,9 +4823,9 @@ export type operations = { targetUserId: string; /** Format: id */ assigneeId: string | null; - reporter: components['schemas']['User']; - targetUser: components['schemas']['User']; - assignee?: components['schemas']['User'] | null; + reporter: components['schemas']['UserDetailedNotMe']; + targetUser: components['schemas']['UserDetailedNotMe']; + assignee?: components['schemas']['UserDetailedNotMe'] | null; })[]; }; }; @@ -4880,7 +4880,7 @@ export type operations = { /** @description OK (with results) */ 200: { content: { - 'application/json': components['schemas']['User']; + 'application/json': components['schemas']['MeDetailed']; }; }; /** @description Client error */ @@ -4985,7 +4985,7 @@ export type operations = { /** @description OK (with results) */ 200: { content: { - 'application/json': components['schemas']['User']; + 'application/json': components['schemas']['UserDetailedNotMe']; }; }; /** @description Client error */ @@ -8133,7 +8133,7 @@ export type operations = { info: Record; /** Format: id */ userId: string; - user: components['schemas']['UserDetailed']; + user: components['schemas']['UserDetailedNotMe']; }[]; }; }; @@ -18291,7 +18291,7 @@ export type operations = { /** @description OK (with results) */ 200: { content: { - 'application/json': components['schemas']['UserDetailed']; + 'application/json': components['schemas']['MeDetailed']; }; }; /** @description Client error */ @@ -22951,7 +22951,7 @@ export type operations = { 'application/json': { /** Format: misskey:id */ id: string; - user: components['schemas']['User']; + user: components['schemas']['UserDetailed']; }[]; }; }; @@ -24746,7 +24746,7 @@ export type operations = { createdAt: string; /** Format: misskey:id */ userId: string; - user: components['schemas']['User']; + user: components['schemas']['UserLite']; withReplies: boolean; }[]; }; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index bab518e635..772d2bbfa1 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -1,5 +1,5 @@ import { ModerationLogPayloads } from './consts.js'; -import { Announcement, EmojiDetailed, MeDetailed, MeDetailedOnly, Page, User, UserDetailed } from './autogen/models.js'; +import { Announcement, EmojiDetailed, MeDetailed, Page, User, UserDetailedNotMe } from './autogen/models.js'; export * from './autogen/entities.js'; export * from './autogen/models.js'; @@ -19,7 +19,7 @@ export type ModerationLog = { id: ID; createdAt: DateString; userId: User['id']; - user: UserDetailed | null; + user: UserDetailedNotMe | null; } & ({ type: 'updateServerSettings'; info: ModerationLogPayloads['updateServerSettings'];