feat(UserEntityService): add isRoot flag on MeDetailed
This commit is contained in:
parent
e1fb94da2e
commit
e85a9dc8e0
3 changed files with 38 additions and 31 deletions
|
@ -469,6 +469,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
const policies = isDetailed ? await this.roleService.getUserPolicies(user.id) : null;
|
const policies = isDetailed ? await this.roleService.getUserPolicies(user.id) : null;
|
||||||
const isModerator = (isMe || iAmModerator) && isDetailed ? this.roleService.isModerator(user) : null;
|
const isModerator = (isMe || iAmModerator) && isDetailed ? this.roleService.isModerator(user) : null;
|
||||||
const isAdmin = (isMe || iAmModerator) && isDetailed ? this.roleService.isAdministrator(user) : null;
|
const isAdmin = (isMe || iAmModerator) && isDetailed ? this.roleService.isAdministrator(user) : null;
|
||||||
|
const isRoot = isMe && isDetailed ? user.isRoot : null;
|
||||||
const unreadAnnouncements = isMe && isDetailed ? await this.announcementService.getUnreadAnnouncements(user) : null;
|
const unreadAnnouncements = isMe && isDetailed ? await this.announcementService.getUnreadAnnouncements(user) : null;
|
||||||
|
|
||||||
const notificationsInfo = isMe && isDetailed ? await this.getNotificationsInfo(user.id) : null;
|
const notificationsInfo = isMe && isDetailed ? await this.getNotificationsInfo(user.id) : null;
|
||||||
|
@ -509,7 +510,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
}))) : undefined,
|
}))) : undefined,
|
||||||
|
|
||||||
...(isDetailed ? {
|
...(isDetailed ? {
|
||||||
url: profile!.url,
|
url: profile?.url,
|
||||||
uri: user.uri,
|
uri: user.uri,
|
||||||
movedTo: user.movedToUri ? this.apPersonService.resolvePerson(user.movedToUri).then(user => user.id).catch(() => null) : null,
|
movedTo: user.movedToUri ? this.apPersonService.resolvePerson(user.movedToUri).then(user => user.id).catch(() => null) : null,
|
||||||
alsoKnownAs: user.alsoKnownAs
|
alsoKnownAs: user.alsoKnownAs
|
||||||
|
@ -525,12 +526,12 @@ export class UserEntityService implements OnModuleInit {
|
||||||
isSilenced: !policies?.canPublicNote,
|
isSilenced: !policies?.canPublicNote,
|
||||||
isLimited: !(policies?.canCreateContent && policies.canUpdateContent && policies.canDeleteContent && policies.canInitiateConversation),
|
isLimited: !(policies?.canCreateContent && policies.canUpdateContent && policies.canDeleteContent && policies.canInitiateConversation),
|
||||||
isSuspended: user.isSuspended,
|
isSuspended: user.isSuspended,
|
||||||
description: profile!.description,
|
description: profile?.description,
|
||||||
location: profile!.location,
|
location: profile?.location,
|
||||||
birthday: profile!.birthday,
|
birthday: profile?.birthday,
|
||||||
lang: profile!.lang,
|
lang: profile?.lang,
|
||||||
fields: profile!.fields,
|
fields: profile?.fields,
|
||||||
verifiedLinks: profile!.verifiedLinks,
|
verifiedLinks: profile?.verifiedLinks,
|
||||||
followersCount: followersCount ?? 0,
|
followersCount: followersCount ?? 0,
|
||||||
followingCount: followingCount ?? 0,
|
followingCount: followingCount ?? 0,
|
||||||
notesCount: user.notesCount,
|
notesCount: user.notesCount,
|
||||||
|
@ -538,14 +539,14 @@ export class UserEntityService implements OnModuleInit {
|
||||||
pinnedNotes: this.noteEntityService.packMany(pins.map(pin => pin.note!), me, {
|
pinnedNotes: this.noteEntityService.packMany(pins.map(pin => pin.note!), me, {
|
||||||
detail: true,
|
detail: true,
|
||||||
}),
|
}),
|
||||||
pinnedPageId: profile!.pinnedPageId,
|
pinnedPageId: profile?.pinnedPageId,
|
||||||
pinnedPage: profile!.pinnedPageId ? this.pageEntityService.pack(profile!.pinnedPageId, me) : null,
|
pinnedPage: profile?.pinnedPageId ? this.pageEntityService.pack(profile.pinnedPageId, me) : null,
|
||||||
publicReactions: this.isLocalUser(user) ? profile!.publicReactions : false, // https://github.com/misskey-dev/misskey/issues/12964
|
publicReactions: this.isLocalUser(user) ? profile?.publicReactions : false, // https://github.com/misskey-dev/misskey/issues/12964
|
||||||
followersVisibility: profile!.followersVisibility,
|
followersVisibility: profile?.followersVisibility,
|
||||||
followingVisibility: profile!.followingVisibility,
|
followingVisibility: profile?.followingVisibility,
|
||||||
twoFactorEnabled: profile!.twoFactorEnabled,
|
twoFactorEnabled: profile?.twoFactorEnabled,
|
||||||
usePasswordLessLogin: profile!.usePasswordLessLogin,
|
usePasswordLessLogin: profile?.usePasswordLessLogin,
|
||||||
securityKeys: profile!.twoFactorEnabled
|
securityKeys: profile?.twoFactorEnabled
|
||||||
? this.userSecurityKeysRepository.countBy({ userId: user.id }).then(result => result >= 1)
|
? this.userSecurityKeysRepository.countBy({ userId: user.id }).then(result => result >= 1)
|
||||||
: false,
|
: false,
|
||||||
roles: this.roleService.getUserRoles(user.id).then(roles => roles
|
roles: this.roleService.getUserRoles(user.id).then(roles => roles
|
||||||
|
@ -563,7 +564,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
}))
|
}))
|
||||||
),
|
),
|
||||||
memo: memo,
|
memo: memo,
|
||||||
moderationNote: iAmModerator ? (profile!.moderationNote ?? '') : undefined,
|
moderationNote: iAmModerator ? (profile?.moderationNote ?? '') : undefined,
|
||||||
} : {}),
|
} : {}),
|
||||||
|
|
||||||
...(isDetailed && (isMe || iAmModerator) ? {
|
...(isDetailed && (isMe || iAmModerator) ? {
|
||||||
|
@ -571,14 +572,15 @@ export class UserEntityService implements OnModuleInit {
|
||||||
bannerId: user.bannerId,
|
bannerId: user.bannerId,
|
||||||
isModerator: isModerator,
|
isModerator: isModerator,
|
||||||
isAdmin: isAdmin,
|
isAdmin: isAdmin,
|
||||||
injectFeaturedNote: profile!.injectFeaturedNote,
|
isRoot: isRoot,
|
||||||
receiveAnnouncementEmail: profile!.receiveAnnouncementEmail,
|
injectFeaturedNote: profile?.injectFeaturedNote,
|
||||||
alwaysMarkNsfw: profile!.alwaysMarkNsfw,
|
receiveAnnouncementEmail: profile?.receiveAnnouncementEmail,
|
||||||
autoSensitive: profile!.autoSensitive,
|
alwaysMarkNsfw: profile?.alwaysMarkNsfw,
|
||||||
carefulBot: profile!.carefulBot,
|
autoSensitive: profile?.autoSensitive,
|
||||||
autoAcceptFollowed: profile!.autoAcceptFollowed,
|
carefulBot: profile?.carefulBot,
|
||||||
noCrawle: profile!.noCrawle,
|
autoAcceptFollowed: profile?.autoAcceptFollowed,
|
||||||
preventAiLearning: profile!.preventAiLearning,
|
noCrawle: profile?.noCrawle,
|
||||||
|
preventAiLearning: profile?.preventAiLearning,
|
||||||
isExplorable: user.isExplorable,
|
isExplorable: user.isExplorable,
|
||||||
isDeleted: user.isDeleted,
|
isDeleted: user.isDeleted,
|
||||||
twoFactorBackupCodesStock: profile?.twoFactorBackupSecret?.length === 20 ? 'full' : (profile?.twoFactorBackupSecret?.length ?? 0) > 0 ? 'partial' : 'none',
|
twoFactorBackupCodesStock: profile?.twoFactorBackupSecret?.length === 20 ? 'full' : (profile?.twoFactorBackupSecret?.length ?? 0) > 0 ? 'partial' : 'none',
|
||||||
|
@ -601,17 +603,17 @@ export class UserEntityService implements OnModuleInit {
|
||||||
mutedWords: profile!.mutedWords,
|
mutedWords: profile!.mutedWords,
|
||||||
mutedInstances: profile!.mutedInstances,
|
mutedInstances: profile!.mutedInstances,
|
||||||
mutingNotificationTypes: [], // 後方互換性のため
|
mutingNotificationTypes: [], // 後方互換性のため
|
||||||
notificationRecieveConfig: profile!.notificationRecieveConfig,
|
notificationRecieveConfig: profile?.notificationRecieveConfig,
|
||||||
emailNotificationTypes: profile!.emailNotificationTypes,
|
emailNotificationTypes: profile?.emailNotificationTypes,
|
||||||
achievements: profile!.achievements,
|
achievements: profile?.achievements,
|
||||||
loggedInDays: profile!.loggedInDates.length,
|
loggedInDays: profile?.loggedInDates.length,
|
||||||
policies: policies,
|
policies: policies,
|
||||||
} : {}),
|
} : {}),
|
||||||
|
|
||||||
...(opts.includeSecrets ? {
|
...(opts.includeSecrets ? {
|
||||||
email: profile!.email,
|
email: profile?.email,
|
||||||
emailVerified: profile!.emailVerified,
|
emailVerified: profile?.emailVerified,
|
||||||
securityKeysList: profile!.twoFactorEnabled
|
securityKeysList: profile?.twoFactorEnabled
|
||||||
? this.userSecurityKeysRepository.find({
|
? this.userSecurityKeysRepository.find({
|
||||||
where: {
|
where: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
|
|
@ -453,6 +453,10 @@ export const packedMeDetailedOnlySchema = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
nullable: true, optional: false,
|
nullable: true, optional: false,
|
||||||
},
|
},
|
||||||
|
isRoot: {
|
||||||
|
type: 'boolean',
|
||||||
|
nullable: true, optional: false,
|
||||||
|
},
|
||||||
injectFeaturedNote: {
|
injectFeaturedNote: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
nullable: false, optional: false,
|
nullable: false, optional: false,
|
||||||
|
|
|
@ -3852,6 +3852,7 @@ export type components = {
|
||||||
bannerId: string | null;
|
bannerId: string | null;
|
||||||
isModerator: boolean | null;
|
isModerator: boolean | null;
|
||||||
isAdmin: boolean | null;
|
isAdmin: boolean | null;
|
||||||
|
isRoot: boolean | null;
|
||||||
injectFeaturedNote: boolean;
|
injectFeaturedNote: boolean;
|
||||||
receiveAnnouncementEmail: boolean;
|
receiveAnnouncementEmail: boolean;
|
||||||
alwaysMarkNsfw: boolean;
|
alwaysMarkNsfw: boolean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue