ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix server lint
Chocobozzz3ca077970a66
diff --git a/packages/tests/src/api/moderation/blocklist.ts b/packages/tests/src/api/moderation/blocklist.tsindex 526ed4016d..5cb2d6a0d2 100644--- a/packages/tests/src/api/moderation/blocklist.ts+++ b/packages/tests/src/api/moderation/blocklist.ts@@ -50,7 +50,7 @@ async function checkCommentNotification (await waitJobs([ mainServer, comment.server ])const { data } = await mainServer.notifications.list({ start: 0, count: 30 })- const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)+ const commentNotifications = data.filter(n => n.comment?.video.uuid === comment.videoUUID && n.createdAt >= createdAt)if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)else expect(commentNotifications).to.have.lengthOf(0)diff --git a/packages/tests/src/api/server/open-telemetry.ts b/packages/tests/src/api/server/open-telemetry.tsindex 2bcf2a39fb..c7fef6c075 100644--- a/packages/tests/src/api/server/open-telemetry.ts+++ b/packages/tests/src/api/server/open-telemetry.ts@@ -113,8 +113,9 @@ describe('Open Telemetry', function () {const res = await makeRawRequest({ url: metricsUrl, expectedStatus: HttpStatusCode.OK_200 })- // eslint-disable-next-line max-len- const label = `{videoOrigin="local",playerMode="p2p-media-loader",resolution="1080",fps="30",p2pEnabled="false",videoUUID="${video.uuid}"}`+ const label =+ // eslint-disable-next-line max-len+ `{videoOrigin="local",playerMode="p2p-media-loader",resolution="1080",fps="30",p2pEnabled="false",videoUUID="${video.uuid}",otel_scope_name="default"}`expect(res.text).to.contain(`peertube_playback_p2p_peers${label} 42`)expect(res.text).to.not.contain(`peertube_playback_p2p_peers${label} 7`)})diff --git a/packages/tests/src/shared/notifications/check-video-notifications.ts b/packages/tests/src/shared/notifications/check-video-notifications.tsindex 06ddb08922..6fdb1f5220 100644--- a/packages/tests/src/shared/notifications/check-video-notifications.ts+++ b/packages/tests/src/shared/notifications/check-video-notifications.ts@@ -23,7 +23,7 @@ export async function checkNewVideoFromSubscription (checkActor(notification.video.channel)} else {expect(notification).to.satisfy((n: UserNotification) => {- return n === undefined || n.type !== UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION || n.video.name !== videoName+ return n?.type !== UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION || n.video.name !== videoName})}}@@ -55,7 +55,7 @@ export async function checkNewLiveFromSubscription (checkActor(notification.video.channel)} else {expect(notification).to.satisfy((n: UserNotification) => {- return n === undefined || n.type !== UserNotificationType.NEW_LIVE_FROM_SUBSCRIPTION || n.video.name !== videoName+ return n?.type !== UserNotificationType.NEW_LIVE_FROM_SUBSCRIPTION || n.video.name !== videoName})}}diff --git a/server/core/controllers/api/accounts.ts b/server/core/controllers/api/accounts.tsindex da98f58ef7..fd2f01bec0 100644--- a/server/core/controllers/api/accounts.ts+++ b/server/core/controllers/api/accounts.ts@@ -194,7 +194,7 @@ async function listAccountPlaylists (req: express.Request, res: express.Response// Allow users to see their private/unlisted video playlistslet listMyPlaylists = false- if (res.locals.oauth && res.locals.oauth.token.User.Account.id === res.locals.account.id) {+ if (res.locals.oauth?.token.User.Account.id === res.locals.account.id) {listMyPlaylists = true}diff --git a/server/core/controllers/api/blocklist.ts b/server/core/controllers/api/blocklist.tsindex 08049431de..01f87d5ffc 100644--- a/server/core/controllers/api/blocklist.ts+++ b/server/core/controllers/api/blocklist.ts@@ -104,7 +104,7 @@ async function populateAccountBlocklistStatus (options: {function getStatus (block: { accountId: number }, serverActor: MActorAccountId, user?: MUserAccountId) {return {- blockedByServer: !!(block && block.accountId === serverActor.Account.id),+ blockedByServer: !!(block?.accountId === serverActor.Account.id),blockedByUser: !!(block && user && block.accountId === user.Account.id)}}diff --git a/server/core/lib/activitypub/url.ts b/server/core/lib/activitypub/url.tsindex 535c6d2def..76de2b4e4d 100644--- a/server/core/lib/activitypub/url.ts+++ b/server/core/lib/activitypub/url.ts@@ -156,5 +156,5 @@ export function checkUrlsSameHost (url1: string, url2: string) {const idHost = new URL(url1).hostconst actorHost = new URL(url2).host- return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()+ return idHost?.toLowerCase() === actorHost?.toLowerCase()}diff --git a/server/core/lib/activitypub/videos/shared/abstract-builder.ts b/server/core/lib/activitypub/videos/shared/abstract-builder.tsindex 9eeac2ead0..6944660dd8 100644--- a/server/core/lib/activitypub/videos/shared/abstract-builder.ts+++ b/server/core/lib/activitypub/videos/shared/abstract-builder.ts@@ -233,7 +233,7 @@ export abstract class APVideoAbstractBuilder {}) {const { video, transaction, oldVideo } = options- if (oldVideo && video.name === oldVideo.name && video.description === oldVideo.description) return+ if (video.name === oldVideo?.name && video.description === oldVideo.description) returnconst automaticTags = await new AutomaticTagger().buildVideoAutomaticTags({ video, transaction })await setAndSaveVideoAutomaticTags({ video, automaticTags, transaction })diff --git a/server/core/lib/plugins/plugin-manager.ts b/server/core/lib/plugins/plugin-manager.tsindex ff64e935e6..2d2a21f3b0 100644--- a/server/core/lib/plugins/plugin-manager.ts+++ b/server/core/lib/plugins/plugin-manager.ts@@ -129,7 +129,7 @@ export class PluginManager implements ServerHook {const npmName = PluginModel.buildNpmName(name, PluginType.PLUGIN)const registered = this.getRegisteredPluginOrTheme(npmName)- if (!registered || registered.type !== PluginType.PLUGIN) return undefined+ if (registered?.type !== PluginType.PLUGIN) return undefinedreturn registered}@@ -138,7 +138,7 @@ export class PluginManager implements ServerHook {const npmName = PluginModel.buildNpmName(name, PluginType.THEME)const registered = this.getRegisteredPluginOrTheme(npmName)- if (!registered || registered.type !== PluginType.THEME) return undefined+ if (registered?.type !== PluginType.THEME) return undefinedreturn registered}@@ -175,14 +175,14 @@ export class PluginManager implements ServerHook {getRegisteredSettings (npmName: string) {const result = this.getRegisteredPluginOrTheme(npmName)- if (!result || result.type !== PluginType.PLUGIN) return []+ if (result?.type !== PluginType.PLUGIN) return []return result.registerHelpers.getSettings()}getRouter (npmName: string) {const result = this.getRegisteredPluginOrTheme(npmName)- if (!result || result.type !== PluginType.PLUGIN) return null+ if (result?.type !== PluginType.PLUGIN) return nullreturn result.registerHelpers.getRouter()}@@ -607,7 +607,7 @@ export class PluginManager implements ServerHook {private getAuth (npmName: string, authName: string) {const plugin = this.getRegisteredPluginOrTheme(npmName)- if (!plugin || plugin.type !== PluginType.PLUGIN) return null+ if (plugin?.type !== PluginType.PLUGIN) return nulllet auths: (RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions)[] = plugin.registerHelpers.getIdAndPassAuths()auths = auths.concat(plugin.registerHelpers.getExternalAuths())diff --git a/server/core/middlewares/activitypub.ts b/server/core/middlewares/activitypub.tsindex 19c7b366b7..8df6076b2d 100644--- a/server/core/middlewares/activitypub.ts+++ b/server/core/middlewares/activitypub.ts@@ -60,7 +60,7 @@ async function checkHttpSignature (req: Request, res: Response) {return wrapWithSpanAndContext('peertube.activitypub.checkHTTPSignature', async () => {// Compatibility with http-signature < v1.3const sig = req.headers['signature'] as string- if (sig && sig.startsWith('Signature ') === true) req.headers['signature'] = sig.replace(/^Signature /, '')+ if (sig?.startsWith('Signature ') === true) req.headers['signature'] = sig.replace(/^Signature /, '')let parsed: ParsedDraftSignaturediff --git a/server/core/middlewares/validators/themes.ts b/server/core/middlewares/validators/themes.tsindex c3e338a964..97a4fca2f0 100644--- a/server/core/middlewares/validators/themes.ts+++ b/server/core/middlewares/validators/themes.ts@@ -19,7 +19,7 @@ export const serveThemeCSSValidator = [const theme = PluginManager.Instance.getRegisteredThemeByShortName(req.params.themeName)- if (!theme || theme.version !== req.params.themeVersion) {+ if (theme?.version !== req.params.themeVersion) {return res.fail({status: HttpStatusCode.NOT_FOUND_404,message: 'No theme named ' + req.params.themeName + ' was found with version ' + req.params.themeVersiondiff --git a/server/core/middlewares/validators/watched-words.ts b/server/core/middlewares/validators/watched-words.tsindex 51e75a9a8b..be0261a122 100644--- a/server/core/middlewares/validators/watched-words.ts+++ b/server/core/middlewares/validators/watched-words.ts@@ -113,7 +113,7 @@ async function checkListNameIsUnique (options: {const { accountId, listName, currentList, res } = optionsconst existing = await WatchedWordsListModel.loadByListName({ accountId, listName })- if (existing && (!currentList || currentList.id !== existing.id)) {+ if (existing && (currentList?.id !== existing.id)) {res.fail({status: HttpStatusCode.BAD_REQUEST_400,message: `Watched words list with name ${listName} already exists`