Refactor (#7394)
* wip * wip * wip * wip * wip * Update define.ts * Update update.ts * Update user.ts * wip * wip * Update request.ts * URL * wip * wip * wip * wip * Update invite.ts * Update create.ts
This commit is contained in:
parent
62cc14c93b
commit
ce340aba7a
109 changed files with 252 additions and 201 deletions
|
@ -147,7 +147,7 @@ export class UserRepository extends Repository<User> {
|
|||
|
||||
public async pack(
|
||||
src: User['id'] | User,
|
||||
me?: User['id'] | User | null | undefined,
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
options?: {
|
||||
detail?: boolean,
|
||||
includeSecrets?: boolean,
|
||||
|
@ -159,7 +159,7 @@ export class UserRepository extends Repository<User> {
|
|||
}, options);
|
||||
|
||||
const user = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
const meId = me ? typeof me === 'string' ? me : me.id : null;
|
||||
const meId = me ? me.id : null;
|
||||
|
||||
const relation = meId && (meId !== user.id) && opts.detail ? await this.getRelation(meId, user.id) : null;
|
||||
const pins = opts.detail ? await UserNotePinings.createQueryBuilder('pin')
|
||||
|
@ -213,11 +213,11 @@ export class UserRepository extends Repository<User> {
|
|||
followingCount: user.followingCount,
|
||||
notesCount: user.notesCount,
|
||||
pinnedNoteIds: pins.map(pin => pin.noteId),
|
||||
pinnedNotes: Notes.packMany(pins.map(pin => pin.note!), meId, {
|
||||
pinnedNotes: Notes.packMany(pins.map(pin => pin.note!), me, {
|
||||
detail: true
|
||||
}),
|
||||
pinnedPageId: profile!.pinnedPageId,
|
||||
pinnedPage: profile!.pinnedPageId ? Pages.pack(profile!.pinnedPageId, meId) : null,
|
||||
pinnedPage: profile!.pinnedPageId ? Pages.pack(profile!.pinnedPageId, me) : null,
|
||||
twoFactorEnabled: profile!.twoFactorEnabled,
|
||||
usePasswordLessLogin: profile!.usePasswordLessLogin,
|
||||
securityKeys: profile!.twoFactorEnabled
|
||||
|
@ -286,7 +286,7 @@ export class UserRepository extends Repository<User> {
|
|||
|
||||
public packMany(
|
||||
users: (User['id'] | User)[],
|
||||
me?: User['id'] | User | null | undefined,
|
||||
me?: { id: User['id'] } | null | undefined,
|
||||
options?: {
|
||||
detail?: boolean,
|
||||
includeSecrets?: boolean,
|
||||
|
@ -295,11 +295,15 @@ export class UserRepository extends Repository<User> {
|
|||
return Promise.all(users.map(u => this.pack(u, me, options)));
|
||||
}
|
||||
|
||||
public isLocalUser(user: User): user is ILocalUser {
|
||||
public isLocalUser(user: User): user is ILocalUser;
|
||||
public isLocalUser<T extends { host: User['host'] }>(user: T): user is T & { host: null; };
|
||||
public isLocalUser(user: User | { host: User['host'] }): boolean {
|
||||
return user.host == null;
|
||||
}
|
||||
|
||||
public isRemoteUser(user: User): user is IRemoteUser {
|
||||
public isRemoteUser(user: User): user is IRemoteUser;
|
||||
public isRemoteUser<T extends { host: User['host'] }>(user: T): user is T & { host: string; };
|
||||
public isRemoteUser(user: User | { host: User['host'] }): boolean {
|
||||
return !this.isLocalUser(user);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue