refactor: resolve #7139
This commit is contained in:
parent
ebadd7fd3f
commit
91172654e4
76 changed files with 107 additions and 221 deletions
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users } from '..';
|
||||
import { AbuseUserReport } from '../entities/abuse-user-report';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
|
||||
@EntityRepository(AbuseUserReport)
|
||||
|
@ -9,7 +8,7 @@ export class AbuseUserReportRepository extends Repository<AbuseUserReport> {
|
|||
public async pack(
|
||||
src: AbuseUserReport['id'] | AbuseUserReport,
|
||||
) {
|
||||
const report = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const report = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: report.id,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Antenna } from '../entities/antenna';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { AntennaNotes, UserGroupJoinings } from '..';
|
||||
|
||||
|
@ -11,7 +10,7 @@ export class AntennaRepository extends Repository<Antenna> {
|
|||
public async pack(
|
||||
src: Antenna['id'] | Antenna,
|
||||
): Promise<PackedAntenna> {
|
||||
const antenna = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const antenna = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
const hasUnreadNote = (await AntennaNotes.findOne({ antennaId: antenna.id, read: false })) != null;
|
||||
const userGroupJoining = antenna.userGroupJoiningId ? await UserGroupJoinings.findOne(antenna.userGroupJoiningId) : null;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { App } from '../entities/app';
|
||||
import { AccessTokens } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
export type PackedApp = SchemaType<typeof packedAppSchema>;
|
||||
|
@ -23,7 +22,7 @@ export class AppRepository extends Repository<App> {
|
|||
includeProfileImageIds: false
|
||||
}, options);
|
||||
|
||||
const app = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const app = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: app.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Apps } from '..';
|
||||
import { AuthSession } from '../entities/auth-session';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
|
||||
@EntityRepository(AuthSession)
|
||||
|
@ -10,7 +9,7 @@ export class AuthSessionRepository extends Repository<AuthSession> {
|
|||
src: AuthSession['id'] | AuthSession,
|
||||
me?: any
|
||||
) {
|
||||
const session = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const session = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: session.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users } from '..';
|
||||
import { Blocking } from '../entities/blocking';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -13,7 +12,7 @@ export class BlockingRepository extends Repository<Blocking> {
|
|||
src: Blocking['id'] | Blocking,
|
||||
me?: any
|
||||
): Promise<PackedBlocking> {
|
||||
const blocking = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const blocking = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: blocking.id,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Channel } from '../entities/channel';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { DriveFiles, ChannelFollowings, NoteUnreads } from '..';
|
||||
import { User } from '../entities/user';
|
||||
|
@ -13,7 +12,7 @@ export class ChannelRepository extends Repository<Channel> {
|
|||
src: Channel['id'] | Channel,
|
||||
me?: User['id'] | User | null | undefined,
|
||||
): Promise<PackedChannel> {
|
||||
const channel = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const channel = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
const meId = me ? typeof me === 'string' ? me : me.id : null;
|
||||
|
||||
const banner = channel.bannerId ? await DriveFiles.findOne(channel.bannerId) : null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Clip } from '../entities/clip';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { Users } from '..';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
|
@ -12,7 +11,7 @@ export class ClipRepository extends Repository<Clip> {
|
|||
public async pack(
|
||||
src: Clip['id'] | Clip,
|
||||
): Promise<PackedClip> {
|
||||
const clip = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const clip = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: clip.id,
|
||||
|
|
|
@ -3,7 +3,6 @@ import { DriveFile } from '../entities/drive-file';
|
|||
import { Users, DriveFolders } from '..';
|
||||
import { User } from '../entities/user';
|
||||
import { toPuny } from '../../misc/convert-host';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import config from '../../config';
|
||||
|
@ -103,7 +102,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
|
|||
self: false
|
||||
}, options);
|
||||
|
||||
const file = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const file = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
const meta = await fetchMeta();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { DriveFolders, DriveFiles } from '..';
|
||||
import { DriveFolder } from '../entities/drive-folder';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -26,7 +25,7 @@ export class DriveFolderRepository extends Repository<DriveFolder> {
|
|||
detail: false
|
||||
}, options);
|
||||
|
||||
const folder = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const folder = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: folder.id,
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Emoji } from '../entities/emoji';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
@EntityRepository(Emoji)
|
||||
export class EmojiRepository extends Repository<Emoji> {
|
||||
public async pack(
|
||||
src: Emoji['id'] | Emoji,
|
||||
) {
|
||||
const emoji = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const emoji = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: emoji.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { FollowRequest } from '../entities/follow-request';
|
||||
import { Users } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
@EntityRepository(FollowRequest)
|
||||
export class FollowRequestRepository extends Repository<FollowRequest> {
|
||||
|
@ -9,7 +8,7 @@ export class FollowRequestRepository extends Repository<FollowRequest> {
|
|||
src: FollowRequest['id'] | FollowRequest,
|
||||
me?: any
|
||||
) {
|
||||
const request = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const request = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: request.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users } from '..';
|
||||
import { Following } from '../entities/following';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -57,7 +56,7 @@ export class FollowingRepository extends Repository<Following> {
|
|||
populateFollower?: boolean;
|
||||
}
|
||||
): Promise<PackedFollowing> {
|
||||
const following = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const following = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
if (opts == null) opts = {};
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users } from '../../..';
|
||||
import { ReversiGame } from '../../../entities/games/reversi/game';
|
||||
import { ensure } from '../../../../prelude/ensure';
|
||||
|
||||
@EntityRepository(ReversiGame)
|
||||
export class ReversiGameRepository extends Repository<ReversiGame> {
|
||||
|
@ -16,7 +15,7 @@ export class ReversiGameRepository extends Repository<ReversiGame> {
|
|||
detail: true
|
||||
}, options);
|
||||
|
||||
const game = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const game = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
const meId = me ? typeof me === 'string' ? me : me.id : null;
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { ReversiMatching } from '../../../entities/games/reversi/matching';
|
||||
import { Users } from '../../..';
|
||||
import { ensure } from '../../../../prelude/ensure';
|
||||
import { awaitAll } from '../../../../prelude/await-all';
|
||||
|
||||
@EntityRepository(ReversiMatching)
|
||||
|
@ -10,7 +9,7 @@ export class ReversiMatchingRepository extends Repository<ReversiMatching> {
|
|||
src: ReversiMatching['id'] | ReversiMatching,
|
||||
me: any
|
||||
) {
|
||||
const matching = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const matching = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: matching.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { MessagingMessage } from '../entities/messaging-message';
|
||||
import { Users, DriveFiles, UserGroups } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
export type PackedMessagingMessage = SchemaType<typeof packedMessagingMessageSchema>;
|
||||
|
@ -25,7 +24,7 @@ export class MessagingMessageRepository extends Repository<MessagingMessage> {
|
|||
populateGroup: true,
|
||||
};
|
||||
|
||||
const message = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const message = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: message.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users } from '..';
|
||||
import { ModerationLog } from '../entities/moderation-log';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
|
||||
@EntityRepository(ModerationLog)
|
||||
|
@ -9,7 +8,7 @@ export class ModerationLogRepository extends Repository<ModerationLog> {
|
|||
public async pack(
|
||||
src: ModerationLog['id'] | ModerationLog,
|
||||
) {
|
||||
const log = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const log = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: log.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users } from '..';
|
||||
import { Muting } from '../entities/muting';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -13,7 +12,7 @@ export class MutingRepository extends Repository<Muting> {
|
|||
src: Muting['id'] | Muting,
|
||||
me?: any
|
||||
): Promise<PackedMuting> {
|
||||
const muting = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const muting = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return await awaitAll({
|
||||
id: muting.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { NoteFavorite } from '../entities/note-favorite';
|
||||
import { Notes } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
@EntityRepository(NoteFavorite)
|
||||
export class NoteFavoriteRepository extends Repository<NoteFavorite> {
|
||||
|
@ -9,7 +8,7 @@ export class NoteFavoriteRepository extends Repository<NoteFavorite> {
|
|||
src: NoteFavorite['id'] | NoteFavorite,
|
||||
me?: any
|
||||
) {
|
||||
const favorite = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const favorite = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: favorite.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { NoteReaction } from '../entities/note-reaction';
|
||||
import { Users } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { convertLegacyReaction } from '../../misc/reaction-lib';
|
||||
|
||||
|
@ -13,7 +12,7 @@ export class NoteReactionRepository extends Repository<NoteReaction> {
|
|||
src: NoteReaction['id'] | NoteReaction,
|
||||
me?: any
|
||||
): Promise<PackedNoteReaction> {
|
||||
const reaction = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const reaction = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: reaction.id,
|
||||
|
|
|
@ -2,7 +2,6 @@ import { EntityRepository, Repository, In } from 'typeorm';
|
|||
import { Note } from '../entities/note';
|
||||
import { User } from '../entities/user';
|
||||
import { Emojis, Users, PollVotes, DriveFiles, NoteReactions, Followings, Polls, Channels } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '../../misc/reaction-lib';
|
||||
|
@ -92,11 +91,11 @@ export class NoteRepository extends Repository<Note> {
|
|||
}, options);
|
||||
|
||||
const meId = me ? typeof me === 'string' ? me : me.id : null;
|
||||
const note = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const note = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
const host = note.userHost;
|
||||
|
||||
async function populatePoll() {
|
||||
const poll = await Polls.findOne(note.id).then(ensure);
|
||||
const poll = await Polls.findOneOrFail(note.id);
|
||||
const choices = poll.choices.map(c => ({
|
||||
text: c,
|
||||
votes: poll.votes[poll.choices.indexOf(c)],
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { Users, Notes, UserGroupInvitations, AccessTokens } from '..';
|
||||
import { Notification } from '../entities/notification';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -12,8 +11,8 @@ export class NotificationRepository extends Repository<Notification> {
|
|||
public async pack(
|
||||
src: Notification['id'] | Notification,
|
||||
): Promise<PackedNotification> {
|
||||
const notification = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const token = notification.appAccessTokenId ? await AccessTokens.findOne(notification.appAccessTokenId).then(ensure) : null;
|
||||
const notification = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
const token = notification.appAccessTokenId ? await AccessTokens.findOneOrFail(notification.appAccessTokenId) : null;
|
||||
|
||||
return await awaitAll({
|
||||
id: notification.id,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { PageLike } from '../entities/page-like';
|
||||
import { Pages } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
@EntityRepository(PageLike)
|
||||
export class PageLikeRepository extends Repository<PageLike> {
|
||||
|
@ -9,7 +8,7 @@ export class PageLikeRepository extends Repository<PageLike> {
|
|||
src: PageLike['id'] | PageLike,
|
||||
me?: any
|
||||
) {
|
||||
const like = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const like = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: like.id,
|
||||
|
|
|
@ -5,7 +5,6 @@ import { Users, DriveFiles, PageLikes } from '..';
|
|||
import { awaitAll } from '../../prelude/await-all';
|
||||
import { DriveFile } from '../entities/drive-file';
|
||||
import { User } from '../entities/user';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
export type PackedPage = SchemaType<typeof packedPageSchema>;
|
||||
|
||||
|
@ -16,7 +15,7 @@ export class PageRepository extends Repository<Page> {
|
|||
me?: User['id'] | User | null | undefined,
|
||||
): Promise<PackedPage> {
|
||||
const meId = me ? typeof me === 'string' ? me : me.id : null;
|
||||
const page = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const page = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
const attachedFiles: Promise<DriveFile | undefined>[] = [];
|
||||
const collectFile = (xs: any[]) => {
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { UserGroupInvitation } from '../entities/user-group-invitation';
|
||||
import { UserGroups } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
@EntityRepository(UserGroupInvitation)
|
||||
export class UserGroupInvitationRepository extends Repository<UserGroupInvitation> {
|
||||
public async pack(
|
||||
src: UserGroupInvitation['id'] | UserGroupInvitation,
|
||||
) {
|
||||
const invitation = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const invitation = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
return {
|
||||
id: invitation.id,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { UserGroup } from '../entities/user-group';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { UserGroupJoinings } from '..';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -11,7 +10,7 @@ export class UserGroupRepository extends Repository<UserGroup> {
|
|||
public async pack(
|
||||
src: UserGroup['id'] | UserGroup,
|
||||
): Promise<PackedUserGroup> {
|
||||
const userGroup = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const userGroup = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
const users = await UserGroupJoinings.find({
|
||||
userGroupId: userGroup.id
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { EntityRepository, Repository } from 'typeorm';
|
||||
import { UserList } from '../entities/user-list';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { UserListJoinings } from '..';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
|
||||
|
@ -11,7 +10,7 @@ export class UserListRepository extends Repository<UserList> {
|
|||
public async pack(
|
||||
src: UserList['id'] | UserList,
|
||||
): Promise<PackedUserList> {
|
||||
const userList = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const userList = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
|
||||
const users = await UserListJoinings.find({
|
||||
userListId: userList.id
|
||||
|
|
|
@ -2,7 +2,6 @@ import $ from 'cafy';
|
|||
import { EntityRepository, Repository, In, Not } from 'typeorm';
|
||||
import { User, ILocalUser, IRemoteUser } from '../entities/user';
|
||||
import { Emojis, Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, Antennas, AntennaNotes, ChannelFollowings, Instances } from '..';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import config from '../../config';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
|
@ -157,7 +156,7 @@ export class UserRepository extends Repository<User> {
|
|||
includeSecrets: false
|
||||
}, options);
|
||||
|
||||
const user = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
const user = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
||||
const meId = me ? typeof me === 'string' ? me : me.id : null;
|
||||
|
||||
const relation = meId && (meId !== user.id) && opts.detail ? await this.getRelation(meId, user.id) : null;
|
||||
|
@ -165,7 +164,7 @@ export class UserRepository extends Repository<User> {
|
|||
where: { userId: user.id },
|
||||
order: { id: 'DESC' }
|
||||
}) : [];
|
||||
const profile = opts.detail ? await UserProfiles.findOne(user.id).then(ensure) : null;
|
||||
const profile = opts.detail ? await UserProfiles.findOneOrFail(user.id) : null;
|
||||
|
||||
const falsy = opts.detail ? false : undefined;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue