From 99b757488c077cee7d0ab89eeec181a7ee6290eb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Nov 2022 15:00:19 +0100 Subject: Fix server lint --- server/lib/activitypub/share.ts | 2 +- server/lib/job-queue/handlers/activitypub-cleaner.ts | 2 +- server/lib/job-queue/handlers/video-import.ts | 2 +- server/lib/moderation.ts | 2 +- server/lib/schedulers/plugins-check-scheduler.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/lib') diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 0fefcbbc5..af0dd510a 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -57,7 +57,7 @@ export { async function addVideoShare (shareUrl: string, video: MVideoId) { const { body } = await doJSONRequest(shareUrl, { activityPub: true }) - if (!body || !body.actor) throw new Error('Body or body actor is invalid') + if (!body?.actor) throw new Error('Body or body actor is invalid') const actorUrl = getAPId(body.actor) if (checkUrlsSameHost(shareUrl, actorUrl) !== true) { diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts index 84c0a2de2..a25f00b0a 100644 --- a/server/lib/job-queue/handlers/activitypub-cleaner.ts +++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts @@ -88,7 +88,7 @@ async function updateObjectIfNeeded (options: { const { body } = await doJSONRequest(url, { activityPub: true }) // If not same id, check same host and update - if (!body || !body.id || !bodyValidator(body)) throw new Error(`Body or body id of ${url} is invalid`) + if (!body?.id || !bodyValidator(body)) throw new Error(`Body or body id of ${url} is invalid`) if (body.type === 'Tombstone') { return on404OrTombstone() diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 83d582cb4..4d361c7b9 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -107,7 +107,7 @@ async function processYoutubeDLImport (job: Job, videoImport: MVideoImportDefaul async function getVideoImportOrDie (payload: VideoImportPayload) { const videoImport = await VideoImportModel.loadAndPopulateVideo(payload.videoImportId) - if (!videoImport || !videoImport.Video) { + if (!videoImport?.Video) { throw new Error(`Cannot import video ${payload.videoImportId}: the video import or video linked to this import does not exist anymore.`) } diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts index 3cc92ca30..dc5d8c83c 100644 --- a/server/lib/moderation.ts +++ b/server/lib/moderation.ts @@ -220,7 +220,7 @@ async function createAbuse (options: { base: FilteredModelAttributes reporterAccount: MAccountDefault flaggedAccount: MAccountLight - associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} > + associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean }> skipNotification: boolean transaction: Transaction }) { diff --git a/server/lib/schedulers/plugins-check-scheduler.ts b/server/lib/schedulers/plugins-check-scheduler.ts index 06450fa01..820c01693 100644 --- a/server/lib/schedulers/plugins-check-scheduler.ts +++ b/server/lib/schedulers/plugins-check-scheduler.ts @@ -33,7 +33,7 @@ export class PluginsCheckScheduler extends AbstractScheduler { const chunks = chunk(plugins, 10) for (const chunk of chunks) { // Find plugins according to their npm name - const pluginIndex: { [npmName: string]: PluginModel} = {} + const pluginIndex: { [npmName: string]: PluginModel } = {} for (const plugin of chunk) { pluginIndex[PluginModel.buildNpmName(plugin.name, plugin.type)] = plugin } -- cgit v1.2.3