diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-03-24 11:05:37 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-24 11:05:37 +0900 |
| commit | ce340aba7a37394c70b9f3d7cece9cfa5e91d94c (patch) | |
| tree | 99612ea0d039f20e0baa9ca243e8cec0af96b11a /src/services/note/create.ts | |
| parent | fix bug (diff) | |
| download | sharkey-ce340aba7a37394c70b9f3d7cece9cfa5e91d94c.tar.gz sharkey-ce340aba7a37394c70b9f3d7cece9cfa5e91d94c.tar.bz2 sharkey-ce340aba7a37394c70b9f3d7cece9cfa5e91d94c.zip | |
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
Diffstat (limited to 'src/services/note/create.ts')
| -rw-r--r-- | src/services/note/create.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 23ccf9042d..64d5513ecc 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -38,14 +38,14 @@ import { getAntennas } from '@/misc/antenna-cache'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; class NotificationManager { - private notifier: User; + private notifier: { id: User['id']; }; private note: Note; private queue: { target: ILocalUser['id']; reason: NotificationType; }[]; - constructor(notifier: User, note: Note) { + constructor(notifier: { id: User['id']; }, note: Note) { this.notifier = notifier; this.note = note; this.queue = []; @@ -112,7 +112,7 @@ type Option = { app?: App | null; }; -export default async (user: User, data: Option, silent = false) => new Promise<Note>(async (res, rej) => { +export default async (user: { id: User['id']; username: User['username']; host: User['host']; isSilenced: User['isSilenced']; }, data: Option, silent = false) => new Promise<Note>(async (res, rej) => { // チャンネル外にリプライしたら対象のスコープに合わせる // (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで) if (data.reply && data.channel && data.reply.channelId !== data.channel.id) { @@ -420,7 +420,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N // この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる // TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい if (count === 1) { - Channels.increment({ id: data.channel.id }, 'usersCount', 1); + Channels.increment({ id: data.channel!.id }, 'usersCount', 1); } }); } @@ -449,7 +449,7 @@ function incRenoteCount(renote: Note) { .execute(); } -async function insertNote(user: User, data: Option, tags: string[], emojis: string[], mentionedUsers: User[]) { +async function insertNote(user: { id: User['id']; host: User['host']; }, data: Option, tags: string[], emojis: string[], mentionedUsers: User[]) { const insert = new Note({ id: genId(data.createdAt!), createdAt: data.createdAt!, @@ -555,7 +555,7 @@ function index(note: Note) { }); } -async function notifyToWatchersOfRenotee(renote: Note, user: User, nm: NotificationManager, type: NotificationType) { +async function notifyToWatchersOfRenotee(renote: Note, user: { id: User['id']; }, nm: NotificationManager, type: NotificationType) { const watchers = await NoteWatchings.find({ noteId: renote.id, userId: Not(user.id) @@ -566,7 +566,7 @@ async function notifyToWatchersOfRenotee(renote: Note, user: User, nm: Notificat } } -async function notifyToWatchersOfReplyee(reply: Note, user: User, nm: NotificationManager) { +async function notifyToWatchersOfReplyee(reply: Note, user: { id: User['id']; }, nm: NotificationManager) { const watchers = await NoteWatchings.find({ noteId: reply.id, userId: Not(user.id) @@ -594,7 +594,7 @@ function saveReply(reply: Note, note: Note) { Notes.increment({ id: reply.id }, 'repliesCount', 1); } -function incNotesCountOfUser(user: User) { +function incNotesCountOfUser(user: { id: User['id']; }) { Users.createQueryBuilder().update() .set({ updatedAt: new Date(), @@ -604,7 +604,7 @@ function incNotesCountOfUser(user: User) { .execute(); } -async function extractMentionedUsers(user: User, tokens: ReturnType<typeof parse>): Promise<User[]> { +async function extractMentionedUsers(user: { host: User['host']; }, tokens: ReturnType<typeof parse>): Promise<User[]> { if (tokens == null) return []; const mentions = extractMentions(tokens); |