diff --git a/src/models/repositories/abuse-user-report.ts b/src/models/repositories/abuse-user-report.ts index c708b265a..61d0d6e22 100644 --- a/src/models/repositories/abuse-user-report.ts +++ b/src/models/repositories/abuse-user-report.ts @@ -6,12 +6,6 @@ import { awaitAll } from '../../prelude/await-all'; @EntityRepository(AbuseUserReport) export class AbuseUserReportRepository extends Repository { - public packMany( - reports: any[], - ) { - return Promise.all(reports.map(x => this.pack(x))); - } - public async pack( src: AbuseUserReport['id'] | AbuseUserReport, ) { @@ -30,4 +24,10 @@ export class AbuseUserReportRepository extends Repository { }), }); } + + public packMany( + reports: any[], + ) { + return Promise.all(reports.map(x => this.pack(x))); + } } diff --git a/src/models/repositories/blocking.ts b/src/models/repositories/blocking.ts index fd209bce1..6ee31cece 100644 --- a/src/models/repositories/blocking.ts +++ b/src/models/repositories/blocking.ts @@ -9,13 +9,6 @@ export type PackedBlocking = SchemaType; @EntityRepository(Blocking) export class BlockingRepository extends Repository { - public packMany( - blockings: any[], - me: any - ) { - return Promise.all(blockings.map(x => this.pack(x, me))); - } - public async pack( src: Blocking['id'] | Blocking, me?: any @@ -31,6 +24,13 @@ export class BlockingRepository extends Repository { }) }); } + + public packMany( + blockings: any[], + me: any + ) { + return Promise.all(blockings.map(x => this.pack(x, me))); + } } export const packedBlockingSchema = { diff --git a/src/models/repositories/drive-file.ts b/src/models/repositories/drive-file.ts index 245db4b79..5e7e1d40f 100644 --- a/src/models/repositories/drive-file.ts +++ b/src/models/repositories/drive-file.ts @@ -67,17 +67,6 @@ export class DriveFileRepository extends Repository { return parseInt(sum, 10) || 0; } - public packMany( - files: any[], - options?: { - detail?: boolean - self?: boolean, - withUser?: boolean, - } - ) { - return Promise.all(files.map(f => this.pack(f, options))); - } - public async pack( src: DriveFile['id'] | DriveFile, options?: { @@ -111,6 +100,17 @@ export class DriveFileRepository extends Repository { user: opts.withUser ? Users.pack(file.userId!) : null }); } + + public packMany( + files: any[], + options?: { + detail?: boolean + self?: boolean, + withUser?: boolean, + } + ) { + return Promise.all(files.map(f => this.pack(f, options))); + } } export const packedDriveFileSchema = { diff --git a/src/models/repositories/following.ts b/src/models/repositories/following.ts index aba6527fa..88fee749a 100644 --- a/src/models/repositories/following.ts +++ b/src/models/repositories/following.ts @@ -49,17 +49,6 @@ export class FollowingRepository extends Repository { return following.followeeHost != null; } - public packMany( - followings: any[], - me?: any, - opts?: { - populateFollowee?: boolean; - populateFollower?: boolean; - } - ) { - return Promise.all(followings.map(x => this.pack(x, me, opts))); - } - public async pack( src: Following['id'] | Following, me?: any, @@ -85,6 +74,17 @@ export class FollowingRepository extends Repository { }) : undefined, }); } + + public packMany( + followings: any[], + me?: any, + opts?: { + populateFollowee?: boolean; + populateFollower?: boolean; + } + ) { + return Promise.all(followings.map(x => this.pack(x, me, opts))); + } } export const packedFollowingSchema = { diff --git a/src/models/repositories/hashtag.ts b/src/models/repositories/hashtag.ts index 22321fca8..a990fa3dc 100644 --- a/src/models/repositories/hashtag.ts +++ b/src/models/repositories/hashtag.ts @@ -6,12 +6,6 @@ export type PackedHashtag = SchemaType; @EntityRepository(Hashtag) export class HashtagRepository extends Repository { - public packMany( - hashtags: Hashtag[], - ) { - return Promise.all(hashtags.map(x => this.pack(x))); - } - public async pack( src: Hashtag, ): Promise { @@ -25,6 +19,12 @@ export class HashtagRepository extends Repository { attachedRemoteUsersCount: src.attachedRemoteUsersCount, }; } + + public packMany( + hashtags: Hashtag[], + ) { + return Promise.all(hashtags.map(x => this.pack(x))); + } } export const packedHashtagSchema = { diff --git a/src/models/repositories/muting.ts b/src/models/repositories/muting.ts index 1e8135a5c..9d99e08a7 100644 --- a/src/models/repositories/muting.ts +++ b/src/models/repositories/muting.ts @@ -9,13 +9,6 @@ export type PackedMuting = SchemaType; @EntityRepository(Muting) export class MutingRepository extends Repository { - public packMany( - mutings: any[], - me: any - ) { - return Promise.all(mutings.map(x => this.pack(x, me))); - } - public async pack( src: Muting['id'] | Muting, me?: any @@ -31,6 +24,13 @@ export class MutingRepository extends Repository { }) }); } + + public packMany( + mutings: any[], + me: any + ) { + return Promise.all(mutings.map(x => this.pack(x, me))); + } } export const packedMutingSchema = { diff --git a/src/models/repositories/note-favorite.ts b/src/models/repositories/note-favorite.ts index f428903c1..5bc638410 100644 --- a/src/models/repositories/note-favorite.ts +++ b/src/models/repositories/note-favorite.ts @@ -5,13 +5,6 @@ import { ensure } from '../../prelude/ensure'; @EntityRepository(NoteFavorite) export class NoteFavoriteRepository extends Repository { - public packMany( - favorites: any[], - me: any - ) { - return Promise.all(favorites.map(x => this.pack(x, me))); - } - public async pack( src: NoteFavorite['id'] | NoteFavorite, me?: any @@ -23,4 +16,11 @@ export class NoteFavoriteRepository extends Repository { note: await Notes.pack(favorite.note || favorite.noteId, me), }; } + + public packMany( + favorites: any[], + me: any + ) { + return Promise.all(favorites.map(x => this.pack(x, me))); + } } diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index 1dbfabe88..7b4627693 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -76,17 +76,6 @@ export class NoteRepository extends Repository { } } - public packMany( - notes: (Note['id'] | Note)[], - me?: User['id'] | User | null | undefined, - options?: { - detail?: boolean; - skipHide?: boolean; - } - ) { - return Promise.all(notes.map(n => this.pack(n, me, options))); - } - public async pack( src: Note['id'] | Note, me?: User['id'] | User | null | undefined, @@ -214,6 +203,17 @@ export class NoteRepository extends Repository { return packed; } + + public packMany( + notes: (Note['id'] | Note)[], + me?: User['id'] | User | null | undefined, + options?: { + detail?: boolean; + skipHide?: boolean; + } + ) { + return Promise.all(notes.map(n => this.pack(n, me, options))); + } } export const packedNoteSchema = { diff --git a/src/models/repositories/notification.ts b/src/models/repositories/notification.ts index cf77b35a0..54eec87cf 100644 --- a/src/models/repositories/notification.ts +++ b/src/models/repositories/notification.ts @@ -9,12 +9,6 @@ export type PackedNotification = SchemaType; @EntityRepository(Notification) export class NotificationRepository extends Repository { - public packMany( - notifications: any[], - ) { - return Promise.all(notifications.map(x => this.pack(x))); - } - public async pack( src: Notification['id'] | Notification, ): Promise { @@ -48,6 +42,12 @@ export class NotificationRepository extends Repository { } : {}) }); } + + public packMany( + notifications: any[], + ) { + return Promise.all(notifications.map(x => this.pack(x))); + } } export const packedNotificationSchema = { diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index 6b212203f..eab3acc8e 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -54,18 +54,6 @@ export class UserRepository extends Repository { }; } - public packMany( - users: (User['id'] | User)[], - me?: User['id'] | User | null | undefined, - options?: { - detail?: boolean, - includeSecrets?: boolean, - includeHasUnreadNotes?: boolean - } - ) { - return Promise.all(users.map(u => this.pack(u, me, options))); - } - public async pack( src: User['id'] | User, me?: User['id'] | User | null | undefined, @@ -187,6 +175,18 @@ export class UserRepository extends Repository { return await awaitAll(packed); } + public packMany( + users: (User['id'] | User)[], + me?: User['id'] | User | null | undefined, + options?: { + detail?: boolean, + includeSecrets?: boolean, + includeHasUnreadNotes?: boolean + } + ) { + return Promise.all(users.map(u => this.pack(u, me, options))); + } + public isLocalUser(user: User): user is ILocalUser { return user.host == null; }