This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -19,13 +19,13 @@ export class AbuseUserReportRepository extends Repository<AbuseUserReport> {
targetUserId: report.targetUserId,
assigneeId: report.assigneeId,
reporter: Users.pack(report.reporter || report.reporterId, null, {
detail: true
detail: true,
}),
targetUser: Users.pack(report.targetUser || report.targetUserId, null, {
detail: true
detail: true,
}),
assignee: report.assigneeId ? Users.pack(report.assignee || report.assigneeId, null, {
detail: true
detail: true,
}) : null,
});
}

View File

@ -27,7 +27,7 @@ export class AntennaRepository extends Repository<Antenna> {
notify: antenna.notify,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
hasUnreadNote
hasUnreadNote,
};
}
}
@ -39,16 +39,16 @@ export const packedAntennaSchema = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'date-time'
format: 'date-time',
},
name: {
type: 'string' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
keywords: {
type: 'array' as const,
@ -58,9 +58,9 @@ export const packedAntennaSchema = {
optional: false as const, nullable: false as const,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
}
optional: false as const, nullable: false as const,
},
},
},
excludeKeywords: {
type: 'array' as const,
@ -70,55 +70,55 @@ export const packedAntennaSchema = {
optional: false as const, nullable: false as const,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
}
optional: false as const, nullable: false as const,
},
},
},
src: {
type: 'string' as const,
optional: false as const, nullable: false as const,
enum: ['home', 'all', 'users', 'list', 'group']
enum: ['home', 'all', 'users', 'list', 'group'],
},
userListId: {
type: 'string' as const,
optional: false as const, nullable: true as const,
format: 'id'
format: 'id',
},
userGroupId: {
type: 'string' as const,
optional: false as const, nullable: true as const,
format: 'id'
format: 'id',
},
users: {
type: 'array' as const,
optional: false as const, nullable: false as const,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
optional: false as const, nullable: false as const,
},
},
caseSensitive: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
default: false
default: false,
},
notify: {
type: 'boolean' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
withReplies: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
default: false
default: false,
},
withFile: {
type: 'boolean' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
hasUnreadNote: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
default: false
}
default: false,
},
},
};

View File

@ -18,7 +18,7 @@ export class AppRepository extends Repository<App> {
const opts = Object.assign({
detail: false,
includeSecret: false,
includeProfileImageIds: false
includeProfileImageIds: false,
}, options);
const app = typeof src === 'object' ? src : await this.findOneOrFail(src);
@ -33,8 +33,8 @@ export class AppRepository extends Repository<App> {
isAuthorized: await AccessTokens.count({
appId: app.id,
userId: me,
}).then(count => count > 0)
} : {})
}).then(count => count > 0),
} : {}),
};
}
}
@ -45,31 +45,31 @@ export const packedAppSchema = {
properties: {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
name: {
type: 'string' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
callbackUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
permission: {
type: 'array' as const,
optional: false as const, nullable: false as const,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
optional: false as const, nullable: false as const,
},
},
secret: {
type: 'string' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
isAuthorized: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
}
}
optional: true as const, nullable: false as const,
},
},
};

View File

@ -15,7 +15,7 @@ export class AuthSessionRepository extends Repository<AuthSession> {
return await awaitAll({
id: session.id,
app: Apps.pack(session.appId, me),
token: session.token
token: session.token,
});
}
}

View File

@ -18,8 +18,8 @@ export class BlockingRepository extends Repository<Blocking> {
createdAt: blocking.createdAt.toISOString(),
blockeeId: blocking.blockeeId,
blockee: Users.pack(blocking.blockeeId, me, {
detail: true
})
detail: true,
}),
});
}
@ -56,5 +56,5 @@ export const packedBlockingSchema = {
optional: false as const, nullable: false as const,
ref: 'User' as const,
},
}
},
};

View File

@ -36,7 +36,7 @@ export class ChannelRepository extends Repository<Channel> {
...(me ? {
isFollowing: following != null,
hasUnreadNote,
} : {})
} : {}),
};
}
}

View File

@ -46,7 +46,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
if (file.uri != null && file.userHost != null && config.mediaProxy != null) {
return appendQuery(config.mediaProxy, query({
url: file.uri,
thumbnail: thumbnail ? '1' : undefined
thumbnail: thumbnail ? '1' : undefined,
}));
}
@ -118,7 +118,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
): Promise<Packed<'DriveFile'> | null> {
const opts = Object.assign({
detail: false,
self: false
self: false,
}, options);
const file = typeof src === 'object' ? src : await this.findOne(src);
@ -141,10 +141,10 @@ export class DriveFileRepository extends Repository<DriveFile> {
comment: file.comment,
folderId: file.folderId,
folder: opts.detail && file.folderId ? DriveFolders.pack(file.folderId, {
detail: true
detail: true,
}) : null,
userId: opts.withUser ? file.userId : null,
user: (opts.withUser && file.userId) ? Users.pack(file.userId) : null
user: (opts.withUser && file.userId) ? Users.pack(file.userId) : null,
});
}
@ -175,23 +175,23 @@ export const packedDriveFileSchema = {
name: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'lenna.jpg'
example: 'lenna.jpg',
},
type: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'image/jpeg'
example: 'image/jpeg',
},
md5: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'md5',
example: '15eca7fba0480996e2245f5185bf39f2'
example: '15eca7fba0480996e2245f5185bf39f2',
},
size: {
type: 'number' as const,
optional: false as const, nullable: false as const,
example: 51469
example: 51469,
},
isSensitive: {
type: 'boolean' as const,
@ -199,7 +199,7 @@ export const packedDriveFileSchema = {
},
blurhash: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
properties: {
type: 'object' as const,
@ -208,24 +208,24 @@ export const packedDriveFileSchema = {
width: {
type: 'number' as const,
optional: true as const, nullable: false as const,
example: 1280
example: 1280,
},
height: {
type: 'number' as const,
optional: true as const, nullable: false as const,
example: 720
example: 720,
},
orientation: {
type: 'number' as const,
optional: true as const, nullable: false as const,
example: 8
example: 8,
},
avgColor: {
type: 'string' as const,
optional: true as const, nullable: false as const,
example: 'rgb(40,65,87)'
}
}
example: 'rgb(40,65,87)',
},
},
},
url: {
type: 'string' as const,
@ -239,7 +239,7 @@ export const packedDriveFileSchema = {
},
comment: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
folderId: {
type: 'string' as const,
@ -262,6 +262,6 @@ export const packedDriveFileSchema = {
type: 'object' as const,
optional: true as const, nullable: true as const,
ref: 'User' as const,
}
},
},
};

View File

@ -20,7 +20,7 @@ export class DriveFolderRepository extends Repository<DriveFolder> {
}
): Promise<Packed<'DriveFolder'>> {
const opts = Object.assign({
detail: false
detail: false,
}, options);
const folder = typeof src === 'object' ? src : await this.findOneOrFail(src);
@ -33,18 +33,18 @@ export class DriveFolderRepository extends Repository<DriveFolder> {
...(opts.detail ? {
foldersCount: DriveFolders.count({
parentId: folder.id
parentId: folder.id,
}),
filesCount: DriveFiles.count({
folderId: folder.id
folderId: folder.id,
}),
...(folder.parentId ? {
parent: this.pack(folder.parentId, {
detail: true
})
} : {})
} : {})
detail: true,
}),
} : {}),
} : {}),
});
}
}

View File

@ -61,5 +61,5 @@ export const packedEmojiSchema = {
type: 'string' as const,
optional: false as const, nullable: false as const,
},
}
},
};

View File

@ -7,100 +7,100 @@ export const packedFederationInstanceSchema = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
caughtAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'date-time'
format: 'date-time',
},
host: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'misskey.example.com'
example: 'misskey.example.com',
},
usersCount: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
notesCount: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
followingCount: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
followersCount: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
driveUsage: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
driveFiles: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
latestRequestSentAt: {
type: 'string' as const,
optional: false as const, nullable: true as const,
format: 'date-time'
format: 'date-time',
},
lastCommunicatedAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'date-time'
format: 'date-time',
},
isNotResponding: {
type: 'boolean' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
isSuspended: {
type: 'boolean' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
softwareName: {
type: 'string' as const,
optional: false as const, nullable: true as const,
example: 'misskey'
example: 'misskey',
},
softwareVersion: {
type: 'string' as const,
optional: false as const, nullable: true as const,
example: config.version
example: config.version,
},
openRegistrations: {
type: 'boolean' as const,
optional: false as const, nullable: true as const,
example: true
example: true,
},
name: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
description: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
maintainerName: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
maintainerEmail: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
iconUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
format: 'url'
format: 'url',
},
infoUpdatedAt: {
type: 'string' as const,
optional: false as const, nullable: true as const,
format: 'date-time'
}
}
format: 'date-time',
},
},
};

View File

@ -65,10 +65,10 @@ export class FollowingRepository extends Repository<Following> {
followeeId: following.followeeId,
followerId: following.followerId,
followee: opts.populateFollowee ? Users.pack(following.followee || following.followeeId, me, {
detail: true
detail: true,
}) : undefined,
follower: opts.populateFollower ? Users.pack(following.follower || following.followerId, me, {
detail: true
detail: true,
}) : undefined,
});
}
@ -120,5 +120,5 @@ export const packedFollowingSchema = {
optional: true as const, nullable: false as const,
ref: 'User' as const,
},
}
},
};

View File

@ -83,8 +83,8 @@ export const packedGalleryPostSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
}
format: 'id',
},
},
files: {
type: 'array' as const,
@ -93,7 +93,7 @@ export const packedGalleryPostSchema = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'DriveFile' as const,
}
},
},
tags: {
type: 'array' as const,
@ -101,11 +101,11 @@ export const packedGalleryPostSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
},
},
isSensitive: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
},
}
},
};

View File

@ -14,7 +14,7 @@ export class ReversiGameRepository extends Repository<ReversiGame> {
}
): Promise<Packed<'ReversiGame'>> {
const opts = Object.assign({
detail: true
detail: true,
}, options);
const game = typeof src === 'object' ? src : await this.findOneOrFail(src);
@ -45,10 +45,10 @@ export class ReversiGameRepository extends Repository<ReversiGame> {
logs: game.logs.map(log => ({
at: log.at.toISOString(),
color: log.color,
pos: log.pos
pos: log.pos,
})),
map: game.map,
} : {})
} : {}),
};
}
}
@ -176,8 +176,8 @@ export const packedReversiGameSchema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
}
},
},
},
map: {
type: 'array' as const,
@ -185,7 +185,7 @@ export const packedReversiGameSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
}
}
},
},
},
};

View File

@ -18,12 +18,12 @@ export class ReversiMatchingRepository extends Repository<ReversiMatching> {
createdAt: matching.createdAt.toISOString(),
parentId: matching.parentId,
parent: Users.pack(matching.parentId, me, {
detail: true
detail: true,
}),
childId: matching.childId,
child: Users.pack(matching.childId, me, {
detail: true
})
detail: true,
}),
});
}
}
@ -65,5 +65,5 @@ export const packedReversiMatchingSchema = {
optional: false as const, nullable: false as const,
ref: 'User' as const,
},
}
},
};

View File

@ -58,5 +58,5 @@ export const packedHashtagSchema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
};

View File

@ -112,8 +112,8 @@ export const packedMessagingMessageSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
}
format: 'id',
},
},
},
};

View File

@ -17,7 +17,7 @@ export class ModerationLogRepository extends Repository<ModerationLog> {
info: log.info,
userId: log.userId,
user: Users.pack(log.user || log.userId, null, {
detail: true
detail: true,
}),
});
}

View File

@ -18,8 +18,8 @@ export class MutingRepository extends Repository<Muting> {
createdAt: muting.createdAt.toISOString(),
muteeId: muting.muteeId,
mutee: Users.pack(muting.muteeId, me, {
detail: true
})
detail: true,
}),
});
}
@ -56,5 +56,5 @@ export const packedMutingSchema = {
optional: false as const, nullable: false as const,
ref: 'User' as const,
},
}
},
};

View File

@ -27,7 +27,7 @@ export class NoteReactionRepository extends Repository<NoteReaction> {
type: convertLegacyReaction(reaction.reaction),
...(opts.withNote ? {
note: await Notes.pack(reaction.noteId, me),
} : {})
} : {}),
};
}
}

View File

@ -51,7 +51,7 @@ export class NoteRepository extends Repository<Note> {
// フォロワーかどうか
const following = await Followings.findOne({
followeeId: note.userId,
followerId: meId
followerId: meId,
});
if (following == null) {
@ -103,7 +103,7 @@ export class NoteRepository extends Repository<Note> {
// フォロワーかどうか
const following = await Followings.findOne({
followeeId: packedNote.userId,
followerId: meId
followerId: meId,
});
if (following == null) {
@ -138,7 +138,7 @@ export class NoteRepository extends Repository<Note> {
): Promise<Packed<'Note'>> {
const opts = Object.assign({
detail: true,
skipHide: false
skipHide: false,
}, options);
const meId = me ? me.id : null;
@ -150,13 +150,13 @@ export class NoteRepository extends Repository<Note> {
const choices = poll.choices.map(c => ({
text: c,
votes: poll.votes[poll.choices.indexOf(c)],
isVoted: false
isVoted: false,
}));
if (poll.multiple) {
const votes = await PollVotes.find({
userId: meId!,
noteId: note.id
noteId: note.id,
});
const myChoices = votes.map(v => v.choice);
@ -166,7 +166,7 @@ export class NoteRepository extends Repository<Note> {
} else {
const vote = await PollVotes.findOne({
userId: meId!,
noteId: note.id
noteId: note.id,
});
if (vote) {
@ -177,7 +177,7 @@ export class NoteRepository extends Repository<Note> {
return {
multiple: poll.multiple,
expiresAt: poll.expiresAt,
choices
choices,
};
}
@ -251,20 +251,20 @@ export class NoteRepository extends Repository<Note> {
...(opts.detail ? {
reply: note.replyId ? this.pack(note.reply || note.replyId, me, {
detail: false,
_hint_: options?._hint_
_hint_: options?._hint_,
}) : undefined,
renote: note.renoteId ? this.pack(note.renote || note.renoteId, me, {
detail: true,
_hint_: options?._hint_
_hint_: options?._hint_,
}) : undefined,
poll: note.hasPoll ? populatePoll() : undefined,
...(meId ? {
myReaction: populateMyReaction()
} : {})
} : {})
myReaction: populateMyReaction(),
} : {}),
} : {}),
});
if (packed.user.isCat && packed.text) {
@ -315,8 +315,8 @@ export class NoteRepository extends Repository<Note> {
return await Promise.all(notes.map(n => this.pack(n, me, {
...options,
_hint_: {
myReactions: myReactionsMap
}
myReactions: myReactionsMap,
},
})));
}
}
@ -390,8 +390,8 @@ export const packedNoteSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
}
format: 'id',
},
},
visibleUserIds: {
type: 'array' as const,
@ -399,8 +399,8 @@ export const packedNoteSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
}
format: 'id',
},
},
fileIds: {
type: 'array' as const,
@ -408,8 +408,8 @@ export const packedNoteSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
}
format: 'id',
},
},
files: {
type: 'array' as const,
@ -418,7 +418,7 @@ export const packedNoteSchema = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'DriveFile' as const,
}
},
},
tags: {
type: 'array' as const,
@ -426,7 +426,7 @@ export const packedNoteSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
},
},
poll: {
type: 'object' as const,

View File

@ -32,40 +32,40 @@ export class NotificationRepository extends Repository<Notification> {
...(notification.type === 'mention' ? {
note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
detail: true,
_hint_: options._hintForEachNotes_
_hint_: options._hintForEachNotes_,
}),
} : {}),
...(notification.type === 'reply' ? {
note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
detail: true,
_hint_: options._hintForEachNotes_
_hint_: options._hintForEachNotes_,
}),
} : {}),
...(notification.type === 'renote' ? {
note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
detail: true,
_hint_: options._hintForEachNotes_
_hint_: options._hintForEachNotes_,
}),
} : {}),
...(notification.type === 'quote' ? {
note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
detail: true,
_hint_: options._hintForEachNotes_
_hint_: options._hintForEachNotes_,
}),
} : {}),
...(notification.type === 'reaction' ? {
note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
detail: true,
_hint_: options._hintForEachNotes_
_hint_: options._hintForEachNotes_,
}),
reaction: notification.reaction
reaction: notification.reaction,
} : {}),
...(notification.type === 'pollVote' ? {
note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
detail: true,
_hint_: options._hintForEachNotes_
_hint_: options._hintForEachNotes_,
}),
choice: notification.choice
choice: notification.choice,
} : {}),
...(notification.type === 'groupInvited' ? {
invitation: UserGroupInvitations.pack(notification.userGroupInvitationId!),
@ -102,8 +102,8 @@ export class NotificationRepository extends Repository<Notification> {
return await Promise.all(notifications.map(x => this.pack(x, {
_hintForEachNotes_: {
myReactions: myReactionsMap
}
myReactions: myReactionsMap,
},
})));
}
}
@ -171,5 +171,5 @@ export const packedNotificationSchema = {
type: 'string' as const,
optional: true as const, nullable: true as const,
},
}
},
};

View File

@ -21,7 +21,7 @@ export class PageRepository extends Repository<Page> {
if (x.type === 'image') {
attachedFiles.push(DriveFiles.findOne({
id: x.fileId,
userId: page.userId
userId: page.userId,
}));
}
if (x.children) {
@ -53,7 +53,7 @@ export class PageRepository extends Repository<Page> {
migrate(page.content);
if (migrated) {
this.update(page.id, {
content: page.content
content: page.content,
});
}
@ -138,5 +138,5 @@ export const packedPageSchema = {
ref: 'User' as const,
optional: false as const, nullable: false as const,
},
}
},
};

View File

@ -4,27 +4,27 @@ export const packedQueueCountSchema = {
properties: {
waiting: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
active: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
completed: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
failed: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
delayed: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
paused: {
type: 'number' as const,
optional: false as const, nullable: false as const
}
}
optional: false as const, nullable: false as const,
},
},
};

View File

@ -11,7 +11,7 @@ export class UserGroupRepository extends Repository<UserGroup> {
const userGroup = typeof src === 'object' ? src : await this.findOneOrFail(src);
const users = await UserGroupJoinings.find({
userGroupId: userGroup.id
userGroupId: userGroup.id,
});
return {
@ -19,7 +19,7 @@ export class UserGroupRepository extends Repository<UserGroup> {
createdAt: userGroup.createdAt.toISOString(),
name: userGroup.name,
ownerId: userGroup.userId,
userIds: users.map(x => x.userId)
userIds: users.map(x => x.userId),
};
}
}
@ -55,7 +55,7 @@ export const packedUserGroupSchema = {
type: 'string' as const,
nullable: false as const, optional: false as const,
format: 'id',
}
},
},
},
};

View File

@ -11,14 +11,14 @@ export class UserListRepository extends Repository<UserList> {
const userList = typeof src === 'object' ? src : await this.findOneOrFail(src);
const users = await UserListJoinings.find({
userListId: userList.id
userListId: userList.id,
});
return {
id: userList.id,
createdAt: userList.createdAt.toISOString(),
name: userList.name,
userIds: users.map(x => x.userId)
userIds: users.map(x => x.userId),
};
}
}
@ -49,7 +49,7 @@ export const packedUserListSchema = {
type: 'string' as const,
nullable: false as const, optional: false as const,
format: 'id',
}
},
},
},
};

View File

@ -15,32 +15,32 @@ export class UserRepository extends Repository<User> {
const [following1, following2, followReq1, followReq2, toBlocking, fromBlocked, mute] = await Promise.all([
Followings.findOne({
followerId: me,
followeeId: target
followeeId: target,
}),
Followings.findOne({
followerId: target,
followeeId: me
followeeId: me,
}),
FollowRequests.findOne({
followerId: me,
followeeId: target
followeeId: target,
}),
FollowRequests.findOne({
followerId: target,
followeeId: me
followeeId: me,
}),
Blockings.findOne({
blockerId: me,
blockeeId: target
blockeeId: target,
}),
Blockings.findOne({
blockerId: target,
blockeeId: me
blockeeId: me,
}),
Mutings.findOne({
muterId: me,
muteeId: target
})
muteeId: target,
}),
]);
return {
@ -51,13 +51,13 @@ export class UserRepository extends Repository<User> {
isFollowed: following2 != null,
isBlocking: toBlocking != null,
isBlocked: fromBlocked != null,
isMuted: mute != null
isMuted: mute != null,
};
}
public async getHasUnreadMessagingMessage(userId: User['id']): Promise<boolean> {
const mute = await Mutings.find({
muterId: userId
muterId: userId,
});
const joinings = await UserGroupJoinings.find({ userId: userId });
@ -76,9 +76,9 @@ export class UserRepository extends Repository<User> {
isRead: false,
...(mute.length > 0 ? { userId: Not(In(mute.map(x => x.muteeId))) } : {}),
},
take: 1
take: 1,
}).then(count => count > 0),
groupQs
groupQs,
]);
return withUser || withGroups.some(x => x);
@ -86,11 +86,11 @@ export class UserRepository extends Repository<User> {
public async getHasUnreadAnnouncement(userId: User['id']): Promise<boolean> {
const reads = await AnnouncementReads.find({
userId: userId
userId: userId,
});
const count = await Announcements.count(reads.length > 0 ? {
id: Not(In(reads.map(read => read.announcementId)))
id: Not(In(reads.map(read => read.announcementId))),
} : {});
return count > 0;
@ -101,7 +101,7 @@ export class UserRepository extends Repository<User> {
const unread = myAntennas.length > 0 ? await AntennaNotes.findOne({
antennaId: In(myAntennas.map(x => x.id)),
read: false
read: false,
}) : null;
return unread != null;
@ -120,7 +120,7 @@ export class UserRepository extends Repository<User> {
public async getHasUnreadNotification(userId: User['id']): Promise<boolean> {
const mute = await Mutings.find({
muterId: userId
muterId: userId,
});
const mutedUserIds = mute.map(m => m.muteeId);
@ -128,9 +128,9 @@ export class UserRepository extends Repository<User> {
where: {
notifieeId: userId,
...(mutedUserIds.length > 0 ? { notifierId: Not(In(mutedUserIds)) } : {}),
isRead: false
isRead: false,
},
take: 1
take: 1,
});
return count > 0;
@ -138,7 +138,7 @@ export class UserRepository extends Repository<User> {
public async getHasPendingReceivedFollowRequest(userId: User['id']): Promise<boolean> {
const count = await FollowRequests.count({
followeeId: userId
followeeId: userId,
});
return count > 0;
@ -173,7 +173,7 @@ export class UserRepository extends Repository<User> {
): Promise<Packed<'User'>> {
const opts = Object.assign({
detail: false,
includeSecrets: false
includeSecrets: false,
}, options);
const user = typeof src === 'object' ? src : await this.findOneOrFail(src);
@ -245,7 +245,7 @@ export class UserRepository extends Repository<User> {
notesCount: user.notesCount,
pinnedNoteIds: pins.map(pin => pin.noteId),
pinnedNotes: Notes.packMany(pins.map(pin => pin.note!), me, {
detail: true
detail: true,
}),
pinnedPageId: profile!.pinnedPageId,
pinnedPage: profile!.pinnedPageId ? Pages.pack(profile!.pinnedPageId, me) : null,
@ -255,7 +255,7 @@ export class UserRepository extends Repository<User> {
usePasswordLessLogin: profile!.usePasswordLessLogin,
securityKeys: profile!.twoFactorEnabled
? UserSecurityKeys.count({
userId: user.id
userId: user.id,
}).then(result => result >= 1)
: false,
} : {}),
@ -274,11 +274,11 @@ export class UserRepository extends Repository<User> {
hideOnlineStatus: user.hideOnlineStatus,
hasUnreadSpecifiedNotes: NoteUnreads.count({
where: { userId: user.id, isSpecified: true },
take: 1
take: 1,
}).then(count => count > 0),
hasUnreadMentions: NoteUnreads.count({
where: { userId: user.id, isMentioned: true },
take: 1
take: 1,
}).then(count => count > 0),
hasUnreadAnnouncement: this.getHasUnreadAnnouncement(user.id),
hasUnreadAntenna: this.getHasUnreadAntenna(user.id),
@ -299,11 +299,11 @@ export class UserRepository extends Repository<User> {
securityKeysList: profile!.twoFactorEnabled
? UserSecurityKeys.find({
where: {
userId: user.id
userId: user.id,
},
select: ['id', 'name', 'lastUsed']
select: ['id', 'name', 'lastUsed'],
})
: []
: [],
} : {}),
...(relation ? {
@ -314,7 +314,7 @@ export class UserRepository extends Repository<User> {
isBlocking: relation.isBlocking,
isBlocked: relation.isBlocked,
isMuted: relation.isMuted,
} : {})
} : {}),
};
return await awaitAll(packed);
@ -366,17 +366,17 @@ export const packedUserSchema = {
name: {
type: 'string' as const,
nullable: true as const, optional: false as const,
example: '藍'
example: '藍',
},
username: {
type: 'string' as const,
nullable: false as const, optional: false as const,
example: 'ai'
example: 'ai',
},
host: {
type: 'string' as const,
nullable: true as const, optional: false as const,
example: 'misskey.example.com'
example: 'misskey.example.com',
},
avatarUrl: {
type: 'string' as const,
@ -390,17 +390,17 @@ export const packedUserSchema = {
avatarColor: {
type: 'any' as const,
nullable: true as const, optional: false as const,
default: null
default: null,
},
isAdmin: {
type: 'boolean' as const,
nullable: false as const, optional: true as const,
default: false
default: false,
},
isModerator: {
type: 'boolean' as const,
nullable: false as const, optional: true as const,
default: false
default: false,
},
isBot: {
type: 'boolean' as const,
@ -419,15 +419,15 @@ export const packedUserSchema = {
properties: {
name: {
type: 'string' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
url: {
type: 'string' as const,
nullable: false as const, optional: false as const,
format: 'url'
format: 'url',
},
}
}
},
},
},
url: {
type: 'string' as const,
@ -456,7 +456,7 @@ export const packedUserSchema = {
bannerColor: {
type: 'any' as const,
nullable: true as const, optional: true as const,
default: null
default: null,
},
isLocked: {
type: 'boolean' as const,
@ -465,12 +465,12 @@ export const packedUserSchema = {
isSuspended: {
type: 'boolean' as const,
nullable: false as const, optional: true as const,
example: false
example: false,
},
description: {
type: 'string' as const,
nullable: true as const, optional: true as const,
example: 'Hi masters, I am Ai!'
example: 'Hi masters, I am Ai!',
},
location: {
type: 'string' as const,
@ -479,7 +479,7 @@ export const packedUserSchema = {
birthday: {
type: 'string' as const,
nullable: true as const, optional: true as const,
example: '2018-03-12'
example: '2018-03-12',
},
fields: {
type: 'array' as const,
@ -490,15 +490,15 @@ export const packedUserSchema = {
properties: {
name: {
type: 'string' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
value: {
type: 'string' as const,
nullable: false as const, optional: false as const
}
nullable: false as const, optional: false as const,
},
},
maxLength: 4
}
maxLength: 4,
},
},
followersCount: {
type: 'number' as const,
@ -519,7 +519,7 @@ export const packedUserSchema = {
type: 'string' as const,
nullable: false as const, optional: false as const,
format: 'id',
}
},
},
pinnedNotes: {
type: 'array' as const,
@ -528,11 +528,11 @@ export const packedUserSchema = {
type: 'object' as const,
nullable: false as const, optional: false as const,
ref: 'Note' as const,
}
},
},
pinnedPageId: {
type: 'string' as const,
nullable: true as const, optional: true as const
nullable: true as const, optional: true as const,
},
pinnedPage: {
type: 'object' as const,
@ -542,47 +542,47 @@ export const packedUserSchema = {
twoFactorEnabled: {
type: 'boolean' as const,
nullable: false as const, optional: true as const,
default: false
default: false,
},
usePasswordLessLogin: {
type: 'boolean' as const,
nullable: false as const, optional: true as const,
default: false
default: false,
},
securityKeys: {
type: 'boolean' as const,
nullable: false as const, optional: true as const,
default: false
default: false,
},
avatarId: {
type: 'string' as const,
nullable: true as const, optional: true as const,
format: 'id'
format: 'id',
},
bannerId: {
type: 'string' as const,
nullable: true as const, optional: true as const,
format: 'id'
format: 'id',
},
autoWatch: {
type: 'boolean' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
injectFeaturedNote: {
type: 'boolean' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
alwaysMarkNsfw: {
type: 'boolean' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
carefulBot: {
type: 'boolean' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
autoAcceptFollowed: {
type: 'boolean' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
hasUnreadSpecifiedNotes: {
type: 'boolean' as const,
@ -618,47 +618,47 @@ export const packedUserSchema = {
},
integrations: {
type: 'object' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
mutedWords: {
type: 'array' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
mutedInstances: {
type: 'array' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
mutingNotificationTypes: {
type: 'array' as const,
nullable: false as const, optional: true as const
nullable: false as const, optional: true as const,
},
isFollowing: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
hasPendingFollowRequestFromYou: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
hasPendingFollowRequestToYou: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
isFollowed: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
isBlocking: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
isBlocked: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
optional: true as const, nullable: false as const,
},
isMuted: {
type: 'boolean' as const,
optional: true as const, nullable: false as const
}
optional: true as const, nullable: false as const,
},
},
};