From 6ce4b3fe2fcd0f7fbeeac8753ee5bb0986ccaad7 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 11 Aug 2022 00:09:29 +0200 Subject: [PATCH] fix some lints Many of these were fixed automatically with eslint --fix. Some of them (e.g. adding return types to functions) were done manually. --- packages/backend/src/mfm/from-html.ts | 2 +- packages/backend/src/misc/acct.ts | 2 +- packages/backend/src/misc/app-lock.ts | 4 ++-- packages/backend/src/misc/captcha.ts | 4 ++-- .../backend/src/misc/check-hit-antenna.ts | 4 ++-- packages/backend/src/misc/convert-host.ts | 2 +- packages/backend/src/misc/create-temp.ts | 2 +- .../backend/src/misc/is-instance-muted.ts | 8 +++---- packages/backend/src/misc/is-user-related.ts | 2 +- packages/backend/src/misc/nyaize.ts | 2 +- .../src/models/entities/abuse-user-report.ts | 2 +- .../backend/src/models/repositories/app.ts | 2 +- .../src/models/repositories/auth-session.ts | 2 +- .../src/models/repositories/blocking.ts | 4 ++-- .../src/models/repositories/drive-folder.ts | 2 +- .../src/models/repositories/follow-request.ts | 2 +- .../src/models/repositories/following.ts | 2 +- .../src/models/repositories/gallery-like.ts | 4 ++-- .../models/repositories/messaging-message.ts | 2 +- .../backend/src/models/repositories/muting.ts | 4 ++-- .../src/models/repositories/note-favorite.ts | 4 ++-- .../src/models/repositories/note-reaction.ts | 2 +- .../backend/src/models/repositories/note.ts | 6 ++--- .../src/models/repositories/notification.ts | 4 ++-- .../src/models/repositories/page-like.ts | 4 ++-- packages/backend/src/models/schema/user.ts | 24 +++++++++---------- packages/backend/src/prelude/await-all.ts | 2 +- packages/backend/src/prelude/time.ts | 12 +++++----- packages/backend/src/queue/index.ts | 6 ++--- .../src/remote/activitypub/audience.ts | 2 +- .../src/remote/activitypub/models/image.ts | 2 +- .../src/remote/activitypub/models/note.ts | 2 +- .../src/remote/activitypub/renderer/person.ts | 4 ++-- .../src/remote/activitypub/resolver.ts | 2 +- .../api/common/read-messaging-message.ts | 6 ++--- .../server/api/common/read-notification.ts | 4 ++-- .../backend/src/server/api/common/signup.ts | 2 +- .../api/endpoints/admin/get-table-stats.ts | 2 +- .../server/api/endpoints/admin/show-user.ts | 2 +- .../server/api/endpoints/antennas/notes.ts | 2 +- .../src/server/api/endpoints/ap/show.ts | 10 ++++---- .../api/endpoints/gallery/posts/create.ts | 2 +- .../api/endpoints/gallery/posts/update.ts | 2 +- .../server/api/endpoints/hashtags/trend.ts | 4 ++-- .../server/api/endpoints/i/gallery/likes.ts | 2 +- .../src/server/api/endpoints/i/page-likes.ts | 2 +- .../src/server/api/endpoints/i/update.ts | 5 ++-- .../backend/src/server/api/endpoints/meta.ts | 2 +- .../server/api/endpoints/notes/children.ts | 1 - packages/backend/src/server/api/error.ts | 2 +- .../src/server/api/openapi/gen-spec.ts | 2 +- .../backend/src/server/api/openapi/schemas.ts | 2 +- .../backend/src/server/api/private/signin.ts | 2 +- packages/backend/src/server/api/streaming.ts | 6 ++--- packages/backend/src/server/nodeinfo.ts | 2 +- packages/backend/src/server/web/manifest.ts | 2 +- .../backend/src/server/web/url-preview.ts | 2 +- packages/backend/src/server/well-known.ts | 10 ++++---- .../src/services/create-notification.ts | 2 +- .../src/services/create-system-user.ts | 2 +- .../backend/src/services/delete-account.ts | 2 +- .../backend/src/services/drive/add-file.ts | 11 ++++----- .../src/services/drive/image-processor.ts | 4 ++-- .../src/services/fetch-instance-metadata.ts | 4 ++-- .../backend/src/services/messages/delete.ts | 6 ++--- packages/backend/src/services/note/create.ts | 4 ++-- packages/backend/src/services/note/delete.ts | 6 ++--- .../backend/src/services/note/polls/update.ts | 2 +- packages/backend/src/services/note/read.ts | 2 +- packages/backend/src/services/note/unread.ts | 2 +- .../backend/src/services/push-notification.ts | 2 +- packages/backend/src/services/send-email.ts | 2 +- packages/backend/src/services/suspend-user.ts | 2 +- .../backend/src/services/update-hashtag.ts | 6 ++--- .../backend/src/services/user-list/push.ts | 2 +- .../services/validate-email-for-account.ts | 12 +++++----- 76 files changed, 142 insertions(+), 143 deletions(-) diff --git a/packages/backend/src/mfm/from-html.ts b/packages/backend/src/mfm/from-html.ts index 52bf56b40..9921c4088 100644 --- a/packages/backend/src/mfm/from-html.ts +++ b/packages/backend/src/mfm/from-html.ts @@ -10,7 +10,7 @@ const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/; export function fromHtml(html: string, hashtagNames?: string[]): string { const dom = parse5.parseFragment( // some AP servers like Pixelfed use br tags as well as newlines - html.replace(/\r?\n/gi, '\n') + html.replace(/\r?\n/gi, '\n'), ); let text = ''; diff --git a/packages/backend/src/misc/acct.ts b/packages/backend/src/misc/acct.ts index 73931365b..60160cc4f 100644 --- a/packages/backend/src/misc/acct.ts +++ b/packages/backend/src/misc/acct.ts @@ -5,7 +5,7 @@ export type Acct = { export function parse(acct: string): Acct { const split = acct.split('@'); - if (split[0].length == 0) { + if (split[0].length === 0) { // there was an initial at split.shift(); } diff --git a/packages/backend/src/misc/app-lock.ts b/packages/backend/src/misc/app-lock.ts index 295c3728e..dedbd6dbf 100644 --- a/packages/backend/src/misc/app-lock.ts +++ b/packages/backend/src/misc/app-lock.ts @@ -9,8 +9,8 @@ const retryDelay = 100; const lock: (key: string, timeout?: number) => Promise<() => void> = redisClient - ? promisify(redisLock(redisClient, retryDelay)) - : async () => () => { }; + ? promisify(redisLock(redisClient, retryDelay)) + : async () => () => { }; /** * Get AP Object lock diff --git a/packages/backend/src/misc/captcha.ts b/packages/backend/src/misc/captcha.ts index 4238116fe..1431a4d80 100644 --- a/packages/backend/src/misc/captcha.ts +++ b/packages/backend/src/misc/captcha.ts @@ -9,7 +9,7 @@ export async function verifyRecaptcha(secret: string, response: string) { }); if (result.success !== true) { - const errorCodes = result['error-codes'] ? result['error-codes']?.join(', ') : ''; + const errorCodes = result['error-codes'] ? result['error-codes'].join(', ') : ''; throw new Error(`recaptcha-failed: ${errorCodes}`); } } @@ -20,7 +20,7 @@ export async function verifyHcaptcha(secret: string, response: string) { }); if (result.success !== true) { - const errorCodes = result['error-codes'] ? result['error-codes']?.join(', ') : ''; + const errorCodes = result['error-codes'] ? result['error-codes'].join(', ') : ''; throw new Error(`hcaptcha-failed: ${errorCodes}`); } } diff --git a/packages/backend/src/misc/check-hit-antenna.ts b/packages/backend/src/misc/check-hit-antenna.ts index 6f39aff75..aa9247b41 100644 --- a/packages/backend/src/misc/check-hit-antenna.ts +++ b/packages/backend/src/misc/check-hit-antenna.ts @@ -65,7 +65,7 @@ export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'No and.every(keyword => antenna.caseSensitive ? note.text!.includes(keyword) - : note.text!.toLowerCase().includes(keyword.toLowerCase()) + : note.text!.toLowerCase().includes(keyword.toLowerCase()), )); if (!matched) return false; @@ -83,7 +83,7 @@ export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'No and.every(keyword => antenna.caseSensitive ? note.text!.includes(keyword) - : note.text!.toLowerCase().includes(keyword.toLowerCase()) + : note.text!.toLowerCase().includes(keyword.toLowerCase()), )); if (matched) return false; diff --git a/packages/backend/src/misc/convert-host.ts b/packages/backend/src/misc/convert-host.ts index 269faeb63..aa771af14 100644 --- a/packages/backend/src/misc/convert-host.ts +++ b/packages/backend/src/misc/convert-host.ts @@ -1,5 +1,5 @@ -import { URL } from 'node:url'; import { toASCII } from 'punycode'; +import { URL } from 'node:url'; import config from '@/config/index.js'; export function getFullApAccount(username: string, host: string | null): string { diff --git a/packages/backend/src/misc/create-temp.ts b/packages/backend/src/misc/create-temp.ts index fa88769de..429977669 100644 --- a/packages/backend/src/misc/create-temp.ts +++ b/packages/backend/src/misc/create-temp.ts @@ -18,7 +18,7 @@ export function createTempDir(): Promise<[string, () => void]> { (e, path, cleanup) => { if (e) return rej(e); res([path, cleanup]); - } + }, ); }); } diff --git a/packages/backend/src/misc/is-instance-muted.ts b/packages/backend/src/misc/is-instance-muted.ts index a74ba524e..d744ba656 100644 --- a/packages/backend/src/misc/is-instance-muted.ts +++ b/packages/backend/src/misc/is-instance-muted.ts @@ -1,15 +1,15 @@ import { Packed } from './schema.js'; export function isInstanceMuted(note: Packed<'Note'>, mutedInstances: Set): boolean { - if (mutedInstances.has(note?.user?.host ?? '')) return true; - if (mutedInstances.has(note?.reply?.user?.host ?? '')) return true; - if (mutedInstances.has(note?.renote?.user?.host ?? '')) return true; + if (mutedInstances.has(note.user.host ?? '')) return true; + if (mutedInstances.has(note.reply?.user.host ?? '')) return true; + if (mutedInstances.has(note.renote?.user.host ?? '')) return true; return false; } export function isUserFromMutedInstance(notif: Packed<'Notification'>, mutedInstances: Set): boolean { - if (mutedInstances.has(notif?.user?.host ?? '')) return true; + if (mutedInstances.has(notif.user?.host ?? '')) return true; return false; } diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index dc7bfbf0a..79eedf914 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -1,7 +1,7 @@ export function isUserRelated(note: any, ids: Set): boolean { if (ids.has(note.userId)) return true; // note author is muted if (note.mentions && note.mentions.some((user: string) => ids.has(user))) return true; // any of mentioned users are muted - if (note.reply && isUserRelated(note.reply, ids)) return true; // also check reply target + if (note.reply && isUserRelated(note.reply, ids)) return true; // also check reply target if (note.renote && isUserRelated(note.renote, ids)) return true; // also check renote target return false; } diff --git a/packages/backend/src/misc/nyaize.ts b/packages/backend/src/misc/nyaize.ts index 500d1db2c..b6b9a9b76 100644 --- a/packages/backend/src/misc/nyaize.ts +++ b/packages/backend/src/misc/nyaize.ts @@ -8,7 +8,7 @@ export function nyaize(text: string): string { .replace(/(?<=every)one/gi, x => x === 'ONE' ? 'NYAN' : 'nyan') // ko-KR .replace(/[나-낳]/g, match => String.fromCharCode( - match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0) + match.charCodeAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0), )) .replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, '다냥') .replace(/(야(?=\?))|(야$)|(야(?= ))/gm, '냥'); diff --git a/packages/backend/src/models/entities/abuse-user-report.ts b/packages/backend/src/models/entities/abuse-user-report.ts index 305c465f0..9e5c4f793 100644 --- a/packages/backend/src/models/entities/abuse-user-report.ts +++ b/packages/backend/src/models/entities/abuse-user-report.ts @@ -52,7 +52,7 @@ export class AbuseUserReport { public resolved: boolean; @Column('boolean', { - default: false + default: false, }) public forwarded: boolean; diff --git a/packages/backend/src/models/repositories/app.ts b/packages/backend/src/models/repositories/app.ts index 9f30442a1..182347e74 100644 --- a/packages/backend/src/models/repositories/app.ts +++ b/packages/backend/src/models/repositories/app.ts @@ -12,7 +12,7 @@ export const AppRepository = db.getRepository(App).extend({ detail?: boolean, includeSecret?: boolean, includeProfileImageIds?: boolean - } + }, ): Promise> { const opts = Object.assign({ detail: false, diff --git a/packages/backend/src/models/repositories/auth-session.ts b/packages/backend/src/models/repositories/auth-session.ts index 55ce446fb..59aec7d9e 100644 --- a/packages/backend/src/models/repositories/auth-session.ts +++ b/packages/backend/src/models/repositories/auth-session.ts @@ -7,7 +7,7 @@ import { Apps } from '../index.js'; export const AuthSessionRepository = db.getRepository(AuthSession).extend({ async pack( src: AuthSession['id'] | AuthSession, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, ) { const session = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); diff --git a/packages/backend/src/models/repositories/blocking.ts b/packages/backend/src/models/repositories/blocking.ts index 1c0b4c9ff..637e04bdb 100644 --- a/packages/backend/src/models/repositories/blocking.ts +++ b/packages/backend/src/models/repositories/blocking.ts @@ -8,7 +8,7 @@ import { Users } from '../index.js'; export const BlockingRepository = db.getRepository(Blocking).extend({ async pack( src: Blocking['id'] | Blocking, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, ): Promise> { const blocking = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); @@ -24,7 +24,7 @@ export const BlockingRepository = db.getRepository(Blocking).extend({ packMany( blockings: any[], - me: { id: User['id'] } + me: { id: User['id'] }, ) { return Promise.all(blockings.map(x => this.pack(x, me))); }, diff --git a/packages/backend/src/models/repositories/drive-folder.ts b/packages/backend/src/models/repositories/drive-folder.ts index 598b909b4..bb744a4b7 100644 --- a/packages/backend/src/models/repositories/drive-folder.ts +++ b/packages/backend/src/models/repositories/drive-folder.ts @@ -9,7 +9,7 @@ export const DriveFolderRepository = db.getRepository(DriveFolder).extend({ src: DriveFolder['id'] | DriveFolder, options?: { detail: boolean - } + }, ): Promise> { const opts = Object.assign({ detail: false, diff --git a/packages/backend/src/models/repositories/follow-request.ts b/packages/backend/src/models/repositories/follow-request.ts index 2bded951b..dc81c35ed 100644 --- a/packages/backend/src/models/repositories/follow-request.ts +++ b/packages/backend/src/models/repositories/follow-request.ts @@ -6,7 +6,7 @@ import { Users } from '../index.js'; export const FollowRequestRepository = db.getRepository(FollowRequest).extend({ async pack( src: FollowRequest['id'] | FollowRequest, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, ) { const request = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); diff --git a/packages/backend/src/models/repositories/following.ts b/packages/backend/src/models/repositories/following.ts index c06c11792..5d4c57af1 100644 --- a/packages/backend/src/models/repositories/following.ts +++ b/packages/backend/src/models/repositories/following.ts @@ -76,7 +76,7 @@ export const FollowingRepository = db.getRepository(Following).extend({ opts?: { populateFollowee?: boolean; populateFollower?: boolean; - } + }, ) { return Promise.all(followings.map(x => this.pack(x, me, opts))); }, diff --git a/packages/backend/src/models/repositories/gallery-like.ts b/packages/backend/src/models/repositories/gallery-like.ts index 08ca4962b..33f5b3ebb 100644 --- a/packages/backend/src/models/repositories/gallery-like.ts +++ b/packages/backend/src/models/repositories/gallery-like.ts @@ -5,7 +5,7 @@ import { GalleryPosts } from '../index.js'; export const GalleryLikeRepository = db.getRepository(GalleryLike).extend({ async pack( src: GalleryLike['id'] | GalleryLike, - me?: any + me?: any, ) { const like = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); @@ -17,7 +17,7 @@ export const GalleryLikeRepository = db.getRepository(GalleryLike).extend({ packMany( likes: any[], - me: any + me: any, ) { return Promise.all(likes.map(x => this.pack(x, me))); }, diff --git a/packages/backend/src/models/repositories/messaging-message.ts b/packages/backend/src/models/repositories/messaging-message.ts index b3a7ea465..8c63bd819 100644 --- a/packages/backend/src/models/repositories/messaging-message.ts +++ b/packages/backend/src/models/repositories/messaging-message.ts @@ -11,7 +11,7 @@ export const MessagingMessageRepository = db.getRepository(MessagingMessage).ext options?: { populateRecipient?: boolean, populateGroup?: boolean, - } + }, ): Promise> { const opts = options || { populateRecipient: true, diff --git a/packages/backend/src/models/repositories/muting.ts b/packages/backend/src/models/repositories/muting.ts index c34e908cf..02ee075d8 100644 --- a/packages/backend/src/models/repositories/muting.ts +++ b/packages/backend/src/models/repositories/muting.ts @@ -8,7 +8,7 @@ import { Users } from '../index.js'; export const MutingRepository = db.getRepository(Muting).extend({ async pack( src: Muting['id'] | Muting, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, ): Promise> { const muting = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); @@ -25,7 +25,7 @@ export const MutingRepository = db.getRepository(Muting).extend({ packMany( mutings: any[], - me: { id: User['id'] } + me: { id: User['id'] }, ) { return Promise.all(mutings.map(x => this.pack(x, me))); }, diff --git a/packages/backend/src/models/repositories/note-favorite.ts b/packages/backend/src/models/repositories/note-favorite.ts index 8d09d6bfb..47d549455 100644 --- a/packages/backend/src/models/repositories/note-favorite.ts +++ b/packages/backend/src/models/repositories/note-favorite.ts @@ -6,7 +6,7 @@ import { Notes } from '../index.js'; export const NoteFavoriteRepository = db.getRepository(NoteFavorite).extend({ async pack( src: NoteFavorite['id'] | NoteFavorite, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, ) { const favorite = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); @@ -21,7 +21,7 @@ export const NoteFavoriteRepository = db.getRepository(NoteFavorite).extend({ packMany( favorites: any[], - me: { id: User['id'] } + me: { id: User['id'] }, ) { return Promise.allSettled(favorites.map(x => this.pack(x, me))) .then(promises => promises.flatMap(result => result.status === 'fulfilled' ? [result.value] : [])); diff --git a/packages/backend/src/models/repositories/note-reaction.ts b/packages/backend/src/models/repositories/note-reaction.ts index b76ec0401..77981d59d 100644 --- a/packages/backend/src/models/repositories/note-reaction.ts +++ b/packages/backend/src/models/repositories/note-reaction.ts @@ -42,5 +42,5 @@ export const NoteReactionRepository = db.getRepository(NoteReaction).extend({ // filter out rejected promises, only keep fulfilled values return reactions.flatMap(result => result.status === 'fulfilled' ? [result.value] : []); - } + }, }); diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index 38080c205..6e5da24fd 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -137,7 +137,7 @@ export const NoteRepository = db.getRepository(Note).extend({ _hint_?: { myReactions: Map; }; - } + }, ): Promise> { const opts = Object.assign({ detail: true, @@ -163,7 +163,7 @@ export const NoteRepository = db.getRepository(Note).extend({ : await Channels.findOneBy({ id: note.channelId }) : null; - const reactionEmojiNames = Object.keys(note.reactions).filter(x => x?.startsWith(':')).map(x => decodeReaction(x).reaction).map(x => x.replace(/:/g, '')); + const reactionEmojiNames = Object.keys(note.reactions).filter(x => x.startsWith(':')).map(x => decodeReaction(x).reaction).map(x => x.replace(/:/g, '')); const packed: Packed<'Note'> = await awaitAll({ id: note.id, @@ -233,7 +233,7 @@ export const NoteRepository = db.getRepository(Note).extend({ me?: { id: User['id'] } | null | undefined, options?: { detail?: boolean; - } + }, ) { if (notes.length === 0) return []; diff --git a/packages/backend/src/models/repositories/notification.ts b/packages/backend/src/models/repositories/notification.ts index 169743ce7..df783351e 100644 --- a/packages/backend/src/models/repositories/notification.ts +++ b/packages/backend/src/models/repositories/notification.ts @@ -16,7 +16,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({ _hintForEachNotes_?: { myReactions: Map; }; - } + }, ): Promise> { const notification = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); const token = notification.appAccessTokenId ? await AccessTokens.findOneByOrFail({ id: notification.appAccessTokenId }) : null; @@ -85,7 +85,7 @@ export const NotificationRepository = db.getRepository(Notification).extend({ async packMany( notifications: Notification[], - meId: User['id'] + meId: User['id'], ) { if (notifications.length === 0) return []; diff --git a/packages/backend/src/models/repositories/page-like.ts b/packages/backend/src/models/repositories/page-like.ts index f4bcbc564..e5d01a05a 100644 --- a/packages/backend/src/models/repositories/page-like.ts +++ b/packages/backend/src/models/repositories/page-like.ts @@ -6,7 +6,7 @@ import { Pages } from '../index.js'; export const PageLikeRepository = db.getRepository(PageLike).extend({ async pack( src: PageLike['id'] | PageLike, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, ) { const like = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src }); @@ -18,7 +18,7 @@ export const PageLikeRepository = db.getRepository(PageLike).extend({ packMany( likes: any[], - me: { id: User['id'] } + me: { id: User['id'] }, ) { return Promise.all(likes.map(x => this.pack(x, me))); }, diff --git a/packages/backend/src/models/schema/user.ts b/packages/backend/src/models/schema/user.ts index 253681695..f2cb995a8 100644 --- a/packages/backend/src/models/schema/user.ts +++ b/packages/backend/src/models/schema/user.ts @@ -161,19 +161,19 @@ export const packedUserDetailedNotMeOnlySchema = { type: 'array', nullable: false, optional: false, items: { - type: 'object', - nullable: false, optional: false, - properties: { - name: { - type: 'string', - nullable: false, optional: false, - }, - value: { - type: 'string', - nullable: false, optional: false, - }, + type: 'object', + nullable: false, optional: false, + properties: { + name: { + type: 'string', + nullable: false, optional: false, }, - maxLength: 4, + value: { + type: 'string', + nullable: false, optional: false, + }, + }, + maxLength: 4, }, }, followersCount: { diff --git a/packages/backend/src/prelude/await-all.ts b/packages/backend/src/prelude/await-all.ts index b955c3a5d..fd9832d6f 100644 --- a/packages/backend/src/prelude/await-all.ts +++ b/packages/backend/src/prelude/await-all.ts @@ -10,7 +10,7 @@ export async function awaitAll(obj: Promiseable): Promise { const resolvedValues = await Promise.all(values.map(value => (!value || !value.constructor || value.constructor.name !== 'Object') ? value - : awaitAll(value) + : awaitAll(value), )); for (let i = 0; i < keys.length; i++) { diff --git a/packages/backend/src/prelude/time.ts b/packages/backend/src/prelude/time.ts index 0da1f7913..06a06debd 100644 --- a/packages/backend/src/prelude/time.ts +++ b/packages/backend/src/prelude/time.ts @@ -6,12 +6,12 @@ const dateTimeIntervals = { export function dateUTC(time: number[]): Date { const d = time.length === 2 ? Date.UTC(time[0], time[1]) - : time.length === 3 ? Date.UTC(time[0], time[1], time[2]) - : time.length === 4 ? Date.UTC(time[0], time[1], time[2], time[3]) - : time.length === 5 ? Date.UTC(time[0], time[1], time[2], time[3], time[4]) - : time.length === 6 ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5]) - : time.length === 7 ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5], time[6]) - : null; + : time.length === 3 ? Date.UTC(time[0], time[1], time[2]) + : time.length === 4 ? Date.UTC(time[0], time[1], time[2], time[3]) + : time.length === 5 ? Date.UTC(time[0], time[1], time[2], time[3], time[4]) + : time.length === 6 ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5]) + : time.length === 7 ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5], time[6]) + : null; if (!d) throw new Error('wrong number of arguments'); diff --git a/packages/backend/src/queue/index.ts b/packages/backend/src/queue/index.ts index dc8c7abd3..1603865b9 100644 --- a/packages/backend/src/queue/index.ts +++ b/packages/backend/src/queue/index.ts @@ -21,9 +21,9 @@ import { ThinUser } from './types.js'; function renderError(e: Error): any { return { - stack: e?.stack, - message: e?.message, - name: e?.name, + stack: e.stack, + message: e.message, + name: e.name, }; } diff --git a/packages/backend/src/remote/activitypub/audience.ts b/packages/backend/src/remote/activitypub/audience.ts index 92a028824..0e2111f0c 100644 --- a/packages/backend/src/remote/activitypub/audience.ts +++ b/packages/backend/src/remote/activitypub/audience.ts @@ -21,7 +21,7 @@ export async function parseAudience(actor: CacheableRemoteUser, to?: ApObject, c const limit = promiseLimit(2); const mentionedUsers = (await Promise.all( - others.map(id => limit(() => resolvePerson(id, resolver).catch(() => null))) + others.map(id => limit(() => resolvePerson(id, resolver).catch(() => null))), )).filter((x): x is CacheableUser => x != null); if (toGroups.public.length > 0) { diff --git a/packages/backend/src/remote/activitypub/models/image.ts b/packages/backend/src/remote/activitypub/models/image.ts index 40da9ac27..bb7ba96df 100644 --- a/packages/backend/src/remote/activitypub/models/image.ts +++ b/packages/backend/src/remote/activitypub/models/image.ts @@ -35,7 +35,7 @@ export async function createImage(actor: CacheableRemoteUser, value: any): Promi uri: image.url, sensitive: image.sensitive, isLink: !instance.cacheRemoteFiles, - comment: truncate(image.name, DB_MAX_IMAGE_COMMENT_LENGTH) + comment: truncate(image.name, DB_MAX_IMAGE_COMMENT_LENGTH), }); if (file.isLink) { diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index ff893bd08..fc915b2a3 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -196,7 +196,7 @@ export async function createNote(value: string | IObject, resolver?: Resolver = // テキストのパース let text: string | null = null; - if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source?.content === 'string') { + if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source.content === 'string') { text = note.source.content; } else if (typeof note._misskey_content !== 'undefined') { text = note._misskey_content; diff --git a/packages/backend/src/remote/activitypub/renderer/person.ts b/packages/backend/src/remote/activitypub/renderer/person.ts index d9c009bcf..213741143 100644 --- a/packages/backend/src/remote/activitypub/renderer/person.ts +++ b/packages/backend/src/remote/activitypub/renderer/person.ts @@ -77,11 +77,11 @@ export async function renderPerson(user: ILocalUser) { attachment: attachment.length ? attachment : undefined, } as any; - if (profile?.birthday) { + if (profile.birthday) { person['vcard:bday'] = profile.birthday; } - if (profile?.location) { + if (profile.location) { person['vcard:Address'] = profile.location; } diff --git a/packages/backend/src/remote/activitypub/resolver.ts b/packages/backend/src/remote/activitypub/resolver.ts index 0fdc19547..4c91e0b67 100644 --- a/packages/backend/src/remote/activitypub/resolver.ts +++ b/packages/backend/src/remote/activitypub/resolver.ts @@ -123,7 +123,7 @@ export default class Resolver { if (parsed.rest == null || !/^\w+$/.test(parsed.rest)) throw new Error('resolveLocal: invalid follow URI'); return Promise.all( - [parsed.id, parsed.rest].map(id => Users.findOneByOrFail({ id })) + [parsed.id, parsed.rest].map(id => Users.findOneByOrFail({ id })), ) .then(([follower, followee]) => renderActivity(renderFollow(follower, followee, url))); default: diff --git a/packages/backend/src/server/api/common/read-messaging-message.ts b/packages/backend/src/server/api/common/read-messaging-message.ts index 99f0f58ee..e8e16f319 100644 --- a/packages/backend/src/server/api/common/read-messaging-message.ts +++ b/packages/backend/src/server/api/common/read-messaging-message.ts @@ -18,7 +18,7 @@ import orderedCollection from '@/remote/activitypub/renderer/ordered-collection. export async function readUserMessagingMessage( userId: User['id'], otherpartyId: User['id'], - messageIds: MessagingMessage['id'][] + messageIds: MessagingMessage['id'][], ) { if (messageIds.length === 0) return; @@ -58,7 +58,7 @@ export async function readUserMessagingMessage( recipientId: userId, isRead: false, }, - take: 1 + take: 1, }); if (!count) { @@ -73,7 +73,7 @@ export async function readUserMessagingMessage( export async function readGroupMessagingMessage( userId: User['id'], groupId: UserGroup['id'], - messageIds: MessagingMessage['id'][] + messageIds: MessagingMessage['id'][], ) { if (messageIds.length === 0) return; diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts index 041610d62..4a1837139 100644 --- a/packages/backend/src/server/api/common/read-notification.ts +++ b/packages/backend/src/server/api/common/read-notification.ts @@ -7,7 +7,7 @@ import { Notifications, Users } from '@/models/index.js'; export async function readNotification( userId: User['id'], - notificationIds: Notification['id'][] + notificationIds: Notification['id'][], ) { if (notificationIds.length === 0) return; @@ -27,7 +27,7 @@ export async function readNotification( export async function readNotificationByQuery( userId: User['id'], - query: Record + query: Record, ) { const notificationIds = await Notifications.findBy({ ...query, diff --git a/packages/backend/src/server/api/common/signup.ts b/packages/backend/src/server/api/common/signup.ts index 7178a7420..f246a454e 100644 --- a/packages/backend/src/server/api/common/signup.ts +++ b/packages/backend/src/server/api/common/signup.ts @@ -64,7 +64,7 @@ export async function signup(opts: { passphrase: undefined, }, } as any, (err, publicKey, privateKey) => - err ? rej(err) : res([publicKey, privateKey]) + err ? rej(err) : res([publicKey, privateKey]), )); let account!: User; diff --git a/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts index aca2540fd..8a0e1350a 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts @@ -28,7 +28,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async () => { const sizes = await - db.query(` + db.query(` SELECT relname AS "table", reltuples as "count", pg_total_relation_size(C.oid) AS "size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts index 78033aed5..bc9c193f8 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts @@ -25,7 +25,7 @@ export const paramDef = { export default define(meta, paramDef, async (ps, me) => { const [user, profile] = await Promise.all([ Users.findOneBy({ id: ps.userId }), - UserProfiles.findOneBy({ userId: ps.userId }) + UserProfiles.findOneBy({ userId: ps.userId }), ]); if (user == null || profile == null) { diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts index a46d6759a..f86b6c7d8 100644 --- a/packages/backend/src/server/api/endpoints/antennas/notes.ts +++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts @@ -58,7 +58,7 @@ export default define(meta, paramDef, async (ps, user) => { } const query = makePaginationQuery(Notes.createQueryBuilder('note'), - ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) + ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) .innerJoin(AntennaNotes.metadata.targetName, 'antennaNote', 'antennaNote.noteId = note.id') .innerJoinAndSelect('note.user', 'user') .leftJoinAndSelect('user.avatar', 'avatar') diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index 7c585c530..cbebf0044 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -47,8 +47,8 @@ export const meta = { type: 'object', optional: false, nullable: false, ref: 'UserDetailedNotMe', - } - } + }, + }, }, { type: 'object', @@ -62,9 +62,9 @@ export const meta = { type: 'object', optional: false, nullable: false, ref: 'Note', - } - } - } + }, + }, + }, ], }, } as const; diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts index 17c64bce3..6757dba1f 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts @@ -47,7 +47,7 @@ export default define(meta, paramDef, async (ps, user) => { DriveFiles.findOneBy({ id: fileId, userId: user.id, - }) + }), ))).filter((file): file is DriveFile => file != null); if (files.length === 0) { diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts index 48a51fc0d..94be32b02 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts @@ -46,7 +46,7 @@ export default define(meta, paramDef, async (ps, user) => { DriveFiles.findOneBy({ id: fileId, userId: user.id, - }) + }), ))).filter((file): file is DriveFile => file != null); if (files.length === 0) { diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts index 069f1bc64..aee186401 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts @@ -127,7 +127,7 @@ export default define(meta, paramDef, async () => { .andWhere('note.createdAt > :gt', { gt: new Date(now.getTime() - (interval * (i + 1))) }) .cache(60000) // 1 min .getRawOne() - .then(x => parseInt(x.count, 10)) + .then(x => parseInt(x.count, 10)), ))); } @@ -140,7 +140,7 @@ export default define(meta, paramDef, async () => { .andWhere('note.createdAt > :gt', { gt: new Date(now.getTime() - rangeA) }) .cache(60000 * 60) // 60 min .getRawOne() - .then(x => parseInt(x.count, 10)) + .then(x => parseInt(x.count, 10)), )); const stats = hots.map((tag, i) => ({ diff --git a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts index 563af4091..f5ceddd43 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts @@ -27,7 +27,7 @@ export const meta = { ref: 'GalleryPost', }, }, - } + }, }, } as const; diff --git a/packages/backend/src/server/api/endpoints/i/page-likes.ts b/packages/backend/src/server/api/endpoints/i/page-likes.ts index 159b9c25b..987387237 100644 --- a/packages/backend/src/server/api/endpoints/i/page-likes.ts +++ b/packages/backend/src/server/api/endpoints/i/page-likes.ts @@ -26,7 +26,7 @@ export const meta = { ref: 'Page', }, }, - } + }, }, } as const; diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 36581c08f..fd2437b3a 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -57,7 +57,7 @@ export const meta = { message: 'Invalid Regular Expression.', code: 'INVALID_REGEXP', id: '0d786918-10df-41cd-8f33-8dec7d9a89a5', - } + }, }, res: { @@ -77,7 +77,8 @@ export const paramDef = { lang: { type: 'string', enum: [null, ...Object.keys(langmap)], nullable: true }, avatarId: { type: 'string', format: 'misskey:id', nullable: true }, bannerId: { type: 'string', format: 'misskey:id', nullable: true }, - fields: { type: 'array', + fields: { + type: 'array', minItems: 0, maxItems: 16, items: { diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 2b6de3756..0d11c5a92 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -1,4 +1,4 @@ -import { IsNull, MoreThan } from 'typeorm'; +import { IsNull } from 'typeorm'; import config from '@/config/index.js'; import { fetchMeta } from '@/misc/fetch-meta.js'; import { Emojis, Users } from '@/models/index.js'; diff --git a/packages/backend/src/server/api/endpoints/notes/children.ts b/packages/backend/src/server/api/endpoints/notes/children.ts index 7357a8212..afd7f41cf 100644 --- a/packages/backend/src/server/api/endpoints/notes/children.ts +++ b/packages/backend/src/server/api/endpoints/notes/children.ts @@ -1,4 +1,3 @@ -import { Brackets } from 'typeorm'; import { Notes } from '@/models/index.js'; import define from '../../define.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js'; diff --git a/packages/backend/src/server/api/error.ts b/packages/backend/src/server/api/error.ts index 0c2fa2aa2..448c7a0c8 100644 --- a/packages/backend/src/server/api/error.ts +++ b/packages/backend/src/server/api/error.ts @@ -16,7 +16,7 @@ export class ApiError extends Error { kind: 'server', httpStatusCode: 500, }, - info?: any | null | undefined + info?: any | null | undefined, ) { super(e.message); this.message = e.message; diff --git a/packages/backend/src/server/api/openapi/gen-spec.ts b/packages/backend/src/server/api/openapi/gen-spec.ts index e3cbf2d47..e929d643e 100644 --- a/packages/backend/src/server/api/openapi/gen-spec.ts +++ b/packages/backend/src/server/api/openapi/gen-spec.ts @@ -37,7 +37,7 @@ export function genOpenapiSpec() { Bearer: { type: 'http', scheme: 'bearer', - } + }, }, }, }; diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index 14bef9cab..4a0844b42 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -55,6 +55,6 @@ export const schemas = { }, ...Object.fromEntries( - Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)]) + Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)]), ), }; diff --git a/packages/backend/src/server/api/private/signin.ts b/packages/backend/src/server/api/private/signin.ts index 4544a75d3..667d721ad 100644 --- a/packages/backend/src/server/api/private/signin.ts +++ b/packages/backend/src/server/api/private/signin.ts @@ -172,7 +172,7 @@ export default async (ctx: Koa.Context) => { body.credentialId .replace(/-/g, '+') .replace(/_/g, '/'), - 'base64' + 'base64', ).toString('hex'), }); diff --git a/packages/backend/src/server/api/streaming.ts b/packages/backend/src/server/api/streaming.ts index 7cf365faf..dff353c2e 100644 --- a/packages/backend/src/server/api/streaming.ts +++ b/packages/backend/src/server/api/streaming.ts @@ -1,6 +1,6 @@ -import * as http from 'node:http'; import { EventEmitter } from 'events'; import { ParsedUrlQuery } from 'querystring'; +import * as http from 'node:http'; import * as websocket from 'websocket'; import { subscriber as redisClient } from '@/db/redis.js'; @@ -8,13 +8,13 @@ import { Users } from '@/models/index.js'; import MainStreamConnection from './stream/index.js'; import authenticate from './authenticate.js'; -export const initializeStreamingServer = (server: http.Server) => { +export const initializeStreamingServer = (server: http.Server): void => { // Init websocket server const ws = new websocket.server({ httpServer: server, }); - ws.on('request', async (request) => { + ws.on('request', async (request): Promise => { const q = request.resourceURL.query as ParsedUrlQuery; const [user, app] = await authenticate(request.httpRequest.headers.authorization, q.i) diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index a4a388ed6..0a67e872d 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -13,7 +13,7 @@ const nodeinfo2_0path = '/nodeinfo/2.0'; export const links = [{ rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1', - href: config.url + nodeinfo2_1path + href: config.url + nodeinfo2_1path, }, { rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: config.url + nodeinfo2_0path, diff --git a/packages/backend/src/server/web/manifest.ts b/packages/backend/src/server/web/manifest.ts index ee568b807..5b10145d4 100644 --- a/packages/backend/src/server/web/manifest.ts +++ b/packages/backend/src/server/web/manifest.ts @@ -2,7 +2,7 @@ import Koa from 'koa'; import { fetchMeta } from '@/misc/fetch-meta.js'; import manifest from './manifest.json' assert { type: 'json' }; -export const manifestHandler = async (ctx: Koa.Context) => { +export const manifestHandler = async (ctx: Koa.Context): Promise => { // TODO //const res = structuredClone(manifest); const res = JSON.parse(JSON.stringify(manifest)); diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts index 10ec4874b..b28e813c6 100644 --- a/packages/backend/src/server/web/url-preview.ts +++ b/packages/backend/src/server/web/url-preview.ts @@ -8,7 +8,7 @@ import { getJson } from '@/misc/fetch.js'; const logger = new Logger('url-preview'); -export const urlPreviewHandler = async (ctx: Koa.Context) => { +export const urlPreviewHandler = async (ctx: Koa.Context): Promise => { const url = ctx.query.url; if (typeof url !== 'string') { ctx.status = 400; diff --git a/packages/backend/src/server/well-known.ts b/packages/backend/src/server/well-known.ts index 91131560e..f4db66354 100644 --- a/packages/backend/src/server/well-known.ts +++ b/packages/backend/src/server/well-known.ts @@ -13,11 +13,11 @@ const router = new Router(); const XRD = (...x: { element: string, value?: string, attributes?: Record }[]) => `${x.map(({ element, value, attributes }) => - `<${ - Object.entries(typeof attributes === 'object' && attributes || {}).reduce((a, [k, v]) => `${a} ${k}="${escapeAttribute(v)}"`, element) - }${ - typeof value === 'string' ? `>${escapeValue(value)}`).reduce((a, c) => a + c, '')}`; + `<${ + Object.entries(typeof attributes === 'object' && attributes || {}).reduce((a, [k, v]) => `${a} ${k}="${escapeAttribute(v)}"`, element) + }${ + typeof value === 'string' ? `>${escapeValue(value)}`).reduce((a, c) => a + c, '')}`; const allPath = '/.well-known/(.*)'; const webFingerPath = '/.well-known/webfinger'; diff --git a/packages/backend/src/services/create-notification.ts b/packages/backend/src/services/create-notification.ts index ece868a1c..6b04bb946 100644 --- a/packages/backend/src/services/create-notification.ts +++ b/packages/backend/src/services/create-notification.ts @@ -9,7 +9,7 @@ import { sendEmailNotification } from './send-email-notification.js'; export async function createNotification( notifieeId: User['id'], type: Notification['type'], - data: Partial + data: Partial, ) { if (data.notifierId && (notifieeId === data.notifierId)) { return null; diff --git a/packages/backend/src/services/create-system-user.ts b/packages/backend/src/services/create-system-user.ts index 8d74c90f2..4f3a3bc01 100644 --- a/packages/backend/src/services/create-system-user.ts +++ b/packages/backend/src/services/create-system-user.ts @@ -10,7 +10,7 @@ import { UsedUsername } from '@/models/entities/used-username.js'; import { db } from '@/db/postgre.js'; import generateNativeUserToken from '../server/api/common/generate-native-user-token.js'; -export async function createSystemUser(username: string) { +export async function createSystemUser(username: string): Promise { const password = uuid(); // Generate hash of password diff --git a/packages/backend/src/services/delete-account.ts b/packages/backend/src/services/delete-account.ts index 0fdceb671..c1ab9e2be 100644 --- a/packages/backend/src/services/delete-account.ts +++ b/packages/backend/src/services/delete-account.ts @@ -8,7 +8,7 @@ export async function deleteAccount(user: { host: string | null; }): Promise { // 物理削除する前にDelete activityを送信する - await doPostSuspend(user).catch(e => {}); + await doPostSuspend(user).catch(() => {}); createDeleteAccountJob(user, { soft: false, diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 9dc6cd174..45d53492d 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -279,7 +279,7 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, _type: string const s3 = getS3(meta); const upload = s3.upload(params, { - partSize: s3.endpoint?.hostname === 'storage.googleapis.com' ? 500 * 1024 * 1024 : 8 * 1024 * 1024, + partSize: s3.endpoint.hostname === 'storage.googleapis.com' ? 500 * 1024 * 1024 : 8 * 1024 * 1024, }); const result = await upload.promise(); @@ -345,7 +345,7 @@ export async function addFile({ isLink = false, url = null, uri = null, - sensitive = null + sensitive = null, }: AddFileArgs): Promise { const info = await getFileInfo(path); logger.info(`${JSON.stringify(info)}`); @@ -431,10 +431,9 @@ export async function addFile({ file.blurhash = info.blurhash || null; file.isLink = isLink; file.isSensitive = user - ? Users.isLocalUser(user) && profile!.alwaysMarkNsfw ? true : - (sensitive !== null && sensitive !== undefined) - ? sensitive - : false + ? Users.isLocalUser(user) && profile!.alwaysMarkNsfw + ? true + : sensitive ?? false : false; if (url !== null) { diff --git a/packages/backend/src/services/drive/image-processor.ts b/packages/backend/src/services/drive/image-processor.ts index 2c564ea59..9b3c95af9 100644 --- a/packages/backend/src/services/drive/image-processor.ts +++ b/packages/backend/src/services/drive/image-processor.ts @@ -38,11 +38,11 @@ export async function convertSharpToJpeg(sharp: sharp.Sharp, width: number, heig * Convert to WebP * with resize, remove metadata, resolve orientation, stop animation */ -export async function convertToWebp(path: string, width: number, height: number, quality: number = 85): Promise { +export async function convertToWebp(path: string, width: number, height: number, quality = 85): Promise { return convertSharpToWebp(await sharp(path), width, height, quality); } -export async function convertSharpToWebp(sharp: sharp.Sharp, width: number, height: number, quality: number = 85): Promise { +export async function convertSharpToWebp(sharp: sharp.Sharp, width: number, height: number, quality = 85): Promise { const data = await sharp .resize(width, height, { fit: 'inside', diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index d318ed74c..f18310fd2 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -235,7 +235,7 @@ async function getSiteName(info: NodeInfo | null, doc: DOMWindow['document'] | n } if (manifest) { - return manifest?.name || manifest?.short_name; + return manifest.name || manifest.short_name; } return null; @@ -261,7 +261,7 @@ async function getDescription(info: NodeInfo | null, doc: DOMWindow['document'] } if (manifest) { - return manifest?.name || manifest?.short_name; + return manifest.name || manifest.short_name; } return null; diff --git a/packages/backend/src/services/messages/delete.ts b/packages/backend/src/services/messages/delete.ts index 1e7ce1981..25f49ae50 100644 --- a/packages/backend/src/services/messages/delete.ts +++ b/packages/backend/src/services/messages/delete.ts @@ -7,12 +7,12 @@ import renderDelete from '@/remote/activitypub/renderer/delete.js'; import renderTombstone from '@/remote/activitypub/renderer/tombstone.js'; import { deliver } from '@/queue/index.js'; -export async function deleteMessage(message: MessagingMessage) { +export async function deleteMessage(message: MessagingMessage): Promise { await MessagingMessages.delete(message.id); - postDeleteMessage(message); + await postDeleteMessage(message); } -async function postDeleteMessage(message: MessagingMessage) { +async function postDeleteMessage(message: MessagingMessage): Promise { if (message.recipientId) { const user = await Users.findOneByOrFail({ id: message.userId }); const recipient = await Users.findOneByOrFail({ id: message.recipientId }); diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 4312deb30..84bfa89eb 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -679,12 +679,12 @@ async function extractMentionedUsers(user: { host: User['host']; }, tokens: mfm. const mentions = extractMentions(tokens); let mentionedUsers = (await Promise.all(mentions.map(m => - resolveUser(m.username, m.host || user.host).catch(() => null) + resolveUser(m.username, m.host || user.host).catch(() => null), ))).filter(x => x != null) as User[]; // Drop duplicate users mentionedUsers = mentionedUsers.filter((u, i, self) => - i === self.findIndex(u2 => u.id === u2.id) + i === self.findIndex(u2 => u.id === u2.id), ); return mentionedUsers; diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index 620a05e1a..fc156b584 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -21,7 +21,7 @@ import { deliverToRelays } from '../relay.js'; * @param user 投稿者 * @param note 投稿 */ -export default async function(user: { id: User['id']; uri: User['uri']; host: User['host']; }, note: Note, quiet = false) { +export default async function(user: { id: User['id']; uri: User['uri']; host: User['host']; }, note: Note, quiet = false): Promise { const deletedAt = new Date(); // この投稿を除く指定したユーザーによる指定したノートのリノートが存在しないとき @@ -83,7 +83,7 @@ export default async function(user: { id: User['id']; uri: User['uri']; host: Us }); } -async function findCascadingNotes(note: Note) { +async function findCascadingNotes(note: Note): Promise { const cascadingNotes: Note[] = []; const recursive = async (noteId: string) => { @@ -105,7 +105,7 @@ async function findCascadingNotes(note: Note) { return cascadingNotes.filter(note => note.userHost === null); // filter out non-local users } -async function getMentionedRemoteUsers(note: Note) { +async function getMentionedRemoteUsers(note: Note): Promise { const where = [] as any[]; // mention / reply / dm diff --git a/packages/backend/src/services/note/polls/update.ts b/packages/backend/src/services/note/polls/update.ts index 68cbb9835..a0ce5f92f 100644 --- a/packages/backend/src/services/note/polls/update.ts +++ b/packages/backend/src/services/note/polls/update.ts @@ -6,7 +6,7 @@ import { Note } from '@/models/entities/note.js'; import { deliverToFollowers } from '@/remote/activitypub/deliver-manager.js'; import { deliverToRelays } from '../../relay.js'; -export async function deliverQuestionUpdate(noteId: Note['id']) { +export async function deliverQuestionUpdate(noteId: Note['id']): Promise { const note = await Notes.findOneBy({ id: noteId }); if (note == null) throw new Error('note not found'); diff --git a/packages/backend/src/services/note/read.ts b/packages/backend/src/services/note/read.ts index 15bf8d3de..0b678893c 100644 --- a/packages/backend/src/services/note/read.ts +++ b/packages/backend/src/services/note/read.ts @@ -18,7 +18,7 @@ export default async function( info?: { following: Set; followingChannels: Set; - } + }, ) { const following = info?.following ? info.following : new Set((await Followings.find({ where: { diff --git a/packages/backend/src/services/note/unread.ts b/packages/backend/src/services/note/unread.ts index d10b37a43..829a024ee 100644 --- a/packages/backend/src/services/note/unread.ts +++ b/packages/backend/src/services/note/unread.ts @@ -8,7 +8,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: { // NOTE: isSpecifiedがtrueならisMentionedは必ずfalse isSpecified: boolean; isMentioned: boolean; -}) { +}): Promise { //#region ミュートしているなら無視 // TODO: 現在の仕様ではChannelにミュートは適用されないのでよしなにケアする const mute = await Mutings.findBy({ diff --git a/packages/backend/src/services/push-notification.ts b/packages/backend/src/services/push-notification.ts index a763f5399..56a8c83bf 100644 --- a/packages/backend/src/services/push-notification.ts +++ b/packages/backend/src/services/push-notification.ts @@ -29,7 +29,7 @@ function truncateNotification(notification: Packed<'Notification'>): any { reply: undefined, renote: undefined, user: undefined as any, // 通知を受け取ったユーザーである場合が多いのでこれも捨てる - } + }, }; } diff --git a/packages/backend/src/services/send-email.ts b/packages/backend/src/services/send-email.ts index 08bc12a30..b4dd0d828 100644 --- a/packages/backend/src/services/send-email.ts +++ b/packages/backend/src/services/send-email.ts @@ -5,7 +5,7 @@ import Logger from './logger.js'; export const logger = new Logger('email'); -export async function sendEmail(to: string, subject: string, html: string, text: string) { +export async function sendEmail(to: string, subject: string, html: string, text: string): Promise { const meta = await fetchMeta(true); const iconUrl = `${config.url}/static-assets/mi-white.png`; diff --git a/packages/backend/src/services/suspend-user.ts b/packages/backend/src/services/suspend-user.ts index df8d034ff..b891a6a1c 100644 --- a/packages/backend/src/services/suspend-user.ts +++ b/packages/backend/src/services/suspend-user.ts @@ -7,7 +7,7 @@ import { User } from '@/models/entities/user.js'; import { Users, Followings } from '@/models/index.js'; import { publishInternalEvent } from '@/services/stream.js'; -export async function doPostSuspend(user: { id: User['id']; host: User['host'] }) { +export async function doPostSuspend(user: { id: User['id']; host: User['host'] }): Promise { publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: true }); if (Users.isLocalUser(user)) { diff --git a/packages/backend/src/services/update-hashtag.ts b/packages/backend/src/services/update-hashtag.ts index 45dfc700e..9f549c3f4 100644 --- a/packages/backend/src/services/update-hashtag.ts +++ b/packages/backend/src/services/update-hashtag.ts @@ -5,13 +5,13 @@ import { genId } from '@/misc/gen-id.js'; import { Hashtag } from '@/models/entities/hashtag.js'; import { normalizeForSearch } from '@/misc/normalize-for-search.js'; -export async function updateHashtags(user: { id: User['id']; host: User['host']; }, tags: string[]) { +export async function updateHashtags(user: { id: User['id']; host: User['host']; }, tags: string[]): Promise { for (const tag of tags) { await updateHashtag(user, tag); } } -export async function updateUsertags(user: User, tags: string[]) { +export async function updateUsertags(user: User, tags: string[]): Promise { for (const tag of tags) { await updateHashtag(user, tag, true, true); } @@ -21,7 +21,7 @@ export async function updateUsertags(user: User, tags: string[]) { } } -export async function updateHashtag(user: { id: User['id']; host: User['host']; }, _tag: string, isUserAttached = false, inc = true) { +export async function updateHashtag(user: { id: User['id']; host: User['host']; }, _tag: string, isUserAttached = false, inc = true): Promise { const tag = normalizeForSearch(_tag); const index = await Hashtags.findOneBy({ name: tag }); diff --git a/packages/backend/src/services/user-list/push.ts b/packages/backend/src/services/user-list/push.ts index d073afcd3..527aa7bf5 100644 --- a/packages/backend/src/services/user-list/push.ts +++ b/packages/backend/src/services/user-list/push.ts @@ -7,7 +7,7 @@ import { genId } from '@/misc/gen-id.js'; import { fetchProxyAccount } from '@/misc/fetch-proxy-account.js'; import createFollowing from '../following/create.js'; -export async function pushUserToUserList(target: User, list: UserList) { +export async function pushUserToUserList(target: User, list: UserList): Promise { await UserListJoinings.insert({ id: genId(), createdAt: new Date(), diff --git a/packages/backend/src/services/validate-email-for-account.ts b/packages/backend/src/services/validate-email-for-account.ts index 132168fb3..3f863fb71 100644 --- a/packages/backend/src/services/validate-email-for-account.ts +++ b/packages/backend/src/services/validate-email-for-account.ts @@ -24,11 +24,11 @@ export async function validateEmailForAccount(emailAddress: string): Promise<{ return { available, reason: available ? null : - exist !== 0 ? 'used' : - validated.reason === 'regex' ? 'format' : - validated.reason === 'disposable' ? 'disposable' : - validated.reason === 'mx' ? 'mx' : - validated.reason === 'smtp' ? 'smtp' : - null, + exist !== 0 ? 'used' : + validated.reason === 'regex' ? 'format' : + validated.reason === 'disposable' ? 'disposable' : + validated.reason === 'mx' ? 'mx' : + validated.reason === 'smtp' ? 'smtp' : + null, }; }