Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix lint

Chocobozzz5477ace574b9
diff --git a/packages/tests/src/api/check-params/runners.ts b/packages/tests/src/api/check-params/runners.ts
index 3badbb42e3..0cc2e570e5 100644
--- a/packages/tests/src/api/check-params/runners.ts
+++ b/packages/tests/src/api/check-params/runners.ts
@@ -819,7 +819,7 @@ describe('Test managing runners', function () {
await server.runnerJobs.success({
jobUUID: job.uuid,
jobToken: job.jobToken,
- payload: { hello: 'video_short.mp4' } as any,
+ payload: { hello: 'video_short.mp4' },
runnerToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
@@ -840,7 +840,7 @@ describe('Test managing runners', function () {
await server.runnerJobs.success({
jobUUID: job.uuid,
jobToken: job.jobToken,
- payload: { videoFile: 'video_short.mp4' } as any,
+ payload: { videoFile: 'video_short.mp4' },
runnerToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
@@ -857,7 +857,7 @@ describe('Test managing runners', function () {
await server.runnerJobs.success({
jobUUID: job.uuid,
jobToken: job.jobToken,
- payload: { hello: 'video_short.mp4' } as any,
+ payload: { hello: 'video_short.mp4' },
runnerToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
@@ -869,7 +869,7 @@ describe('Test managing runners', function () {
await server.runnerJobs.success({
jobUUID: studioAcceptedJob.uuid,
jobToken: studioAcceptedJob.jobToken,
- payload: { hello: 'video_short.mp4' } as any,
+ payload: { hello: 'video_short.mp4' },
runnerToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
diff --git a/packages/tests/src/api/check-params/video-embed-privacy.ts b/packages/tests/src/api/check-params/video-embed-privacy.ts
index 896ca12056..604b458fc4 100644
--- a/packages/tests/src/api/check-params/video-embed-privacy.ts
+++ b/packages/tests/src/api/check-params/video-embed-privacy.ts
@@ -193,7 +193,7 @@ describe('Test video embed privacy validator', function () {
it('Should fail with missing policy', async function () {
await server.videoEmbedPrivacy.update({
videoId: video.id,
- policy: undefined as any,
+ policy: undefined,
domains: [],
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
@@ -219,7 +219,7 @@ describe('Test video embed privacy validator', function () {
await server.videoEmbedPrivacy.update({
videoId: video.id,
policy: VideoEmbedPrivacyPolicy.ALL_ALLOWED,
- domains: undefined as any,
+ domains: undefined,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
diff --git a/packages/tests/src/api/check-params/video-studio.ts b/packages/tests/src/api/check-params/video-studio.ts
index 13de04eef9..3be56fbf1d 100644
--- a/packages/tests/src/api/check-params/video-studio.ts
+++ b/packages/tests/src/api/check-params/video-studio.ts
@@ -422,7 +422,7 @@ describe('Test video studio API validator', function () {
it('Should fail with invalid segment end', async function () {
await removeSegments([ { start: 1, end: 0 } ])
- await removeSegments([ { start: 1, end: -1 } ] as any)
+ await removeSegments([ { start: 1, end: -1 } ])
await removeSegments([ { start: 1, end: 'tintin' } ] as any)
})
diff --git a/packages/tests/src/api/check-params/views-and-stats.ts b/packages/tests/src/api/check-params/views-and-stats.ts
index f6466d47f2..541ab437b7 100644
--- a/packages/tests/src/api/check-params/views-and-stats.ts
+++ b/packages/tests/src/api/check-params/views-and-stats.ts
@@ -123,7 +123,7 @@ describe('Test videos views API validators', function () {
it('Should fail with an invalid start date', async function () {
await testEndpoint({
videoId,
- startDate: 'fake' as any,
+ startDate: 'fake',
endDate: new Date().toISOString(),
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
@@ -133,7 +133,7 @@ describe('Test videos views API validators', function () {
await testEndpoint({
videoId,
startDate: new Date().toISOString(),
- endDate: 'fake' as any,
+ endDate: 'fake',
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
diff --git a/packages/tests/src/api/server/cancel-job.ts b/packages/tests/src/api/server/cancel-job.ts
index 5f8674a225..fda86853c1 100644
--- a/packages/tests/src/api/server/cancel-job.ts
+++ b/packages/tests/src/api/server/cancel-job.ts
@@ -1,7 +1,7 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { wait } from '@peertube/peertube-core-utils'
-import { Job, JobState, JobType, VideoDetails, VideoPrivacy, VideoStudioTask } from '@peertube/peertube-models'
+import { Job, JobType, VideoDetails, VideoPrivacy, VideoStudioTask } from '@peertube/peertube-models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands'
import { generateHighBitrateVideo } from '@tests/shared/generate.js'
import { expect } from 'chai'
@@ -29,7 +29,7 @@ async function waitForJobCancellation (server: PeerTubeServer, uuid: string, job
}
async function findActiveJobByUUID (server: PeerTubeServer, uuid: string, jobType: JobType) {
- const { data } = await server.jobs.list({ state: 'active' as JobState, jobType })
+ const { data } = await server.jobs.list({ state: 'active', jobType })
return data.find(j => j.data?.videoUUID === uuid)
}
diff --git a/packages/tests/src/api/server/config.ts b/packages/tests/src/api/server/config.ts
index 49b9300919..5461928b26 100644
--- a/packages/tests/src/api/server/config.ts
+++ b/packages/tests/src/api/server/config.ts
@@ -188,7 +188,7 @@ function buildNewCustomConfig (server: PeerTubeServer): CustomConfig {
categories: [ 1, 2 ],
isNSFW: true,
- defaultNSFWPolicy: 'warn' as 'warn',
+ defaultNSFWPolicy: 'warn',
serverCountry: 'France',
support: {
diff --git a/packages/tests/src/api/server/follows.ts b/packages/tests/src/api/server/follows.ts
index ac422a55f1..21cc936d1f 100644
--- a/packages/tests/src/api/server/follows.ts
+++ b/packages/tests/src/api/server/follows.ts
@@ -509,8 +509,8 @@ describe('Test follows', function () {
expect(comment.account.name).to.equal('root')
expect(comment.account.host).to.equal(servers[2].host)
expect(comment.totalReplies).to.equal(3)
- expect(dateIsValid(comment.createdAt as string)).to.be.true
- expect(dateIsValid(comment.updatedAt as string)).to.be.true
+ expect(dateIsValid(comment.createdAt)).to.be.true
+ expect(dateIsValid(comment.updatedAt)).to.be.true
const threadId = comment.threadId
@@ -540,7 +540,7 @@ describe('Test follows', function () {
expect(deletedComment.inReplyToCommentId).to.be.null
expect(deletedComment.account).to.be.null
expect(deletedComment.totalReplies).to.equal(2)
- expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
+ expect(dateIsValid(deletedComment.deletedAt)).to.be.true
const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId: deletedComment.threadId })
const [ commentRoot, deletedChildRoot ] = tree.children
diff --git a/packages/tests/src/api/server/jobs.ts b/packages/tests/src/api/server/jobs.ts
index ae95f884ef..9dd382c2e7 100644
--- a/packages/tests/src/api/server/jobs.ts
+++ b/packages/tests/src/api/server/jobs.ts
@@ -57,9 +57,9 @@ describe('Test jobs', function () {
if (job.type === 'videos-stats') job = body.data[1]
expect(job.state).to.equal('completed')
- expect(dateIsValid(job.createdAt as string)).to.be.true
- expect(dateIsValid(job.processedOn as string)).to.be.true
- expect(dateIsValid(job.finishedOn as string)).to.be.true
+ expect(dateIsValid(job.createdAt)).to.be.true
+ expect(dateIsValid(job.processedOn)).to.be.true
+ expect(dateIsValid(job.finishedOn)).to.be.true
}
{
diff --git a/packages/tests/src/api/users/login-lockout.ts b/packages/tests/src/api/users/login-lockout.ts
index 2f528be3b8..ebbb712901 100644
--- a/packages/tests/src/api/users/login-lockout.ts
+++ b/packages/tests/src/api/users/login-lockout.ts
@@ -80,7 +80,7 @@ describe('Test login lockout', function () {
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
- expectGenericInvalidGrant(body as unknown as PeerTubeProblemDocument)
+ expectGenericInvalidGrant(body)
}
before(async function () {
diff --git a/packages/tests/src/api/videos/multiple-servers.ts b/packages/tests/src/api/videos/multiple-servers.ts
index 3733d3b828..fdcc9fb3cd 100644
--- a/packages/tests/src/api/videos/multiple-servers.ts
+++ b/packages/tests/src/api/videos/multiple-servers.ts
@@ -872,8 +872,8 @@ describe('Test multiple servers', function () {
expect(comment.account.name).to.equal('root')
expect(comment.account.host).to.equal(servers[0].host)
expect(comment.totalReplies).to.equal(3)
- expect(dateIsValid(comment.createdAt as string)).to.be.true
- expect(dateIsValid(comment.updatedAt as string)).to.be.true
+ expect(dateIsValid(comment.createdAt)).to.be.true
+ expect(dateIsValid(comment.updatedAt)).to.be.true
}
{
@@ -883,8 +883,8 @@ describe('Test multiple servers', function () {
expect(comment.account.name).to.equal('root')
expect(comment.account.host).to.equal(servers[2].host)
expect(comment.totalReplies).to.equal(0)
- expect(dateIsValid(comment.createdAt as string)).to.be.true
- expect(dateIsValid(comment.updatedAt as string)).to.be.true
+ expect(dateIsValid(comment.createdAt)).to.be.true
+ expect(dateIsValid(comment.updatedAt)).to.be.true
}
}
})
@@ -977,8 +977,8 @@ describe('Test multiple servers', function () {
expect(comment.account.name).to.equal('root')
expect(comment.account.host).to.equal(servers[2].host)
expect(comment.totalReplies).to.equal(0)
- expect(dateIsValid(comment.createdAt as string)).to.be.true
- expect(dateIsValid(comment.updatedAt as string)).to.be.true
+ expect(dateIsValid(comment.createdAt)).to.be.true
+ expect(dateIsValid(comment.updatedAt)).to.be.true
}
{
@@ -990,9 +990,9 @@ describe('Test multiple servers', function () {
expect(deletedComment.inReplyToCommentId).to.be.null
expect(deletedComment.account).to.be.null
expect(deletedComment.totalReplies).to.equal(2)
- expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
- expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
- expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
+ expect(dateIsValid(deletedComment.createdAt)).to.be.true
+ expect(dateIsValid(deletedComment.updatedAt)).to.be.true
+ expect(dateIsValid(deletedComment.deletedAt)).to.be.true
}
}
})
diff --git a/packages/tests/src/api/videos/video-comments.ts b/packages/tests/src/api/videos/video-comments.ts
index 6580e9087f..4b0b0f5fad 100644
--- a/packages/tests/src/api/videos/video-comments.ts
+++ b/packages/tests/src/api/videos/video-comments.ts
@@ -71,8 +71,8 @@ describe('Test video comments', function () {
expect(comment.account.url).to.equal(server.url + '/accounts/root')
expect(comment.totalReplies).to.equal(0)
expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
- expect(dateIsValid(comment.createdAt as string)).to.be.true
- expect(dateIsValid(comment.updatedAt as string)).to.be.true
+ expect(dateIsValid(comment.createdAt)).to.be.true
+ expect(dateIsValid(comment.updatedAt)).to.be.true
})
it('Should list threads of this video', async function () {
@@ -97,8 +97,8 @@ describe('Test video comments', function () {
expect(comment.totalReplies).to.equal(0)
expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
- expect(dateIsValid(comment.createdAt as string)).to.be.true
- expect(dateIsValid(comment.updatedAt as string)).to.be.true
+ expect(dateIsValid(comment.createdAt)).to.be.true
+ expect(dateIsValid(comment.updatedAt)).to.be.true
threadId = comment.threadId
})
@@ -110,8 +110,8 @@ describe('Test video comments', function () {
expect(rootComment.inReplyToCommentId).to.be.null
expect(rootComment.text).equal('my super first comment')
expect(rootComment.videoId).to.equal(videoId)
- expect(dateIsValid(rootComment.createdAt as string)).to.be.true
- expect(dateIsValid(rootComment.updatedAt as string)).to.be.true
+ expect(dateIsValid(rootComment.createdAt)).to.be.true
+ expect(dateIsValid(rootComment.updatedAt)).to.be.true
})
it('Should create multiple replies in this thread', async function () {
diff --git a/packages/tests/src/server-lib/video-constant-registry-factory.ts b/packages/tests/src/server-lib/video-constant-registry-factory.ts
index 74060dbff0..63ade2418d 100644
--- a/packages/tests/src/server-lib/video-constant-registry-factory.ts
+++ b/packages/tests/src/server-lib/video-constant-registry-factory.ts
@@ -60,7 +60,7 @@ describe('VideoConstantManagerFactory', function () {
it('Should be able to add a video licence constant', () => {
const successfullyAdded = videoLicenceManager.addConstant(42, 'European Union Public Licence')
expect(successfullyAdded).to.be.true
- expect(videoLicenceManager.getConstantValue(42 as any)).to.equal('European Union Public Licence')
+ expect(videoLicenceManager.getConstantValue(42)).to.equal('European Union Public Licence')
})
it('Should be able to reset video licence constants', () => {
diff --git a/server/core/controllers/api/runners/jobs.ts b/server/core/controllers/api/runners/jobs.ts
index 2447e5375a..11ccc88b5e 100644
--- a/server/core/controllers/api/runners/jobs.ts
+++ b/server/core/controllers/api/runners/jobs.ts
@@ -323,7 +323,7 @@ async function updateRunnerJobController (req: express.Request, res: express.Res
const payloadBuilder = jobUpdateBuilders[runnerJob.type]
const updatePayload = payloadBuilder
- ? payloadBuilder(body.payload, req.files as UploadFiles)
+ ? payloadBuilder(body.payload, req.files)
: undefined
logger.debug(
@@ -408,7 +408,7 @@ async function postRunnerJobSuccess (req: express.Request, res: express.Response
const runner = runnerJob.Runner
const body: RunnerJobSuccessBody = req.body
- const resultPayload = jobSuccessPayloadBuilders[runnerJob.type](body.payload, req.files as UploadFiles)
+ const resultPayload = jobSuccessPayloadBuilders[runnerJob.type](body.payload, req.files)
logger.info(
'Remote runner %s is sending success result for job %s (%s)',
diff --git a/server/core/controllers/api/server/debug.ts b/server/core/controllers/api/server/debug.ts
index e848fc8a8f..2814f9dac1 100644
--- a/server/core/controllers/api/server/debug.ts
+++ b/server/core/controllers/api/server/debug.ts
@@ -1,5 +1,4 @@
import {
- Debug,
HttpStatusCode,
SendDebugCommand,
SendDebugTestEmails,
@@ -53,7 +52,7 @@ function getDebug (req: express.Request, res: express.Response) {
return res.json({
ip: req.ip,
activityPubMessagesWaiting: InboxManager.Instance.getActivityPubMessagesWaiting()
- } as Debug)
+ })
}
async function runCommand (req: express.Request, res: express.Response) {
diff --git a/server/core/controllers/api/users/index.ts b/server/core/controllers/api/users/index.ts
index 65628879c9..0aeedb2ebb 100644
--- a/server/core/controllers/api/users/index.ts
+++ b/server/core/controllers/api/users/index.ts
@@ -1,5 +1,5 @@
import { pick } from '@peertube/peertube-core-utils'
-import { HttpStatusCode, UserCreate, UserCreateResult, UserRight, UserUpdate } from '@peertube/peertube-models'
+import { HttpStatusCode, UserCreate, UserRight, UserUpdate } from '@peertube/peertube-models'
import { tokensRouter } from '@server/controllers/api/users/token.js'
import { retryTransactionWrapper } from '@server/helpers/database-utils.js'
import { CONFIG } from '@server/initializers/config.js'
@@ -207,7 +207,7 @@ async function createUser (req: express.Request, res: express.Response) {
account: {
id: account.id
}
- } as UserCreateResult
+ }
})
}
diff --git a/server/core/controllers/api/users/token.ts b/server/core/controllers/api/users/token.ts
index 155573eb39..9e915f0b2d 100644
--- a/server/core/controllers/api/users/token.ts
+++ b/server/core/controllers/api/users/token.ts
@@ -1,5 +1,5 @@
import { InvalidGrantError } from '@node-oauth/oauth2-server'
-import { ResultList, ScopedToken, TokenSession } from '@peertube/peertube-models'
+import { ResultList, TokenSession } from '@peertube/peertube-models'
import { buildUUID } from '@peertube/peertube-node-utils'
import { logger } from '@server/helpers/logger.js'
import { CONFIG } from '@server/initializers/config.js'
@@ -186,7 +186,7 @@ function getScopedTokens (req: express.Request, res: express.Response) {
return res.json({
feedToken: user.feedToken
- } as ScopedToken)
+ })
}
async function renewScopedTokens (req: express.Request, res: express.Response) {
@@ -197,7 +197,7 @@ async function renewScopedTokens (req: express.Request, res: express.Response) {
return res.json({
feedToken: user.feedToken
- } as ScopedToken)
+ })
}
async function buildByPassLogin (req: express.Request, grantType: string): Promise<BypassLogin> {
diff --git a/server/core/controllers/api/users/two-factor.ts b/server/core/controllers/api/users/two-factor.ts
index 180a670883..f34cfa17dd 100644
--- a/server/core/controllers/api/users/two-factor.ts
+++ b/server/core/controllers/api/users/two-factor.ts
@@ -9,18 +9,20 @@ import {
disableTwoFactorValidator,
requestOrConfirmTwoFactorValidator
} from '@server/middlewares/validators/two-factor.js'
-import { HttpStatusCode, TwoFactorEnableResult } from '@peertube/peertube-models'
+import { HttpStatusCode } from '@peertube/peertube-models'
const twoFactorRouter = express.Router()
-twoFactorRouter.post('/:id/two-factor/request',
+twoFactorRouter.post(
+ '/:id/two-factor/request',
authenticate,
asyncMiddleware(usersCheckCurrentPasswordFactory(req => req.params.id)),
asyncMiddleware(requestOrConfirmTwoFactorValidator),
asyncMiddleware(requestTwoFactor)
)
-twoFactorRouter.post('/:id/two-factor/confirm-request',
+twoFactorRouter.post(
+ '/:id/two-factor/confirm-request',
confirmTokenRateLimiter,
authenticate,
asyncMiddleware(requestOrConfirmTwoFactorValidator),
@@ -28,7 +30,8 @@ twoFactorRouter.post('/:id/two-factor/confirm-request',
asyncMiddleware(confirmRequestTwoFactor)
)
-twoFactorRouter.post('/:id/two-factor/disable',
+twoFactorRouter.post(
+ '/:id/two-factor/disable',
authenticate,
asyncMiddleware(usersCheckCurrentPasswordFactory(req => req.params.id)),
asyncMiddleware(disableTwoFactorValidator),
@@ -57,7 +60,7 @@ async function requestTwoFactor (req: express.Request, res: express.Response) {
secret,
uri
}
- } as TwoFactorEnableResult)
+ })
}
async function confirmRequestTwoFactor (req: express.Request, res: express.Response) {
diff --git a/server/core/controllers/api/users/user-exports.ts b/server/core/controllers/api/users/user-exports.ts
index 05201d7e33..434db680c9 100644
--- a/server/core/controllers/api/users/user-exports.ts
+++ b/server/core/controllers/api/users/user-exports.ts
@@ -1,5 +1,5 @@
import express from 'express'
-import { FileStorage, HttpStatusCode, UserExportRequest, UserExportRequestResult, UserExportState } from '@peertube/peertube-models'
+import { FileStorage, HttpStatusCode, UserExportRequest, UserExportState } from '@peertube/peertube-models'
import {
asyncMiddleware,
authenticate,
@@ -65,7 +65,7 @@ async function requestExport (req: express.Request, res: express.Response) {
export: {
id: exportModel.id
}
- } as UserExportRequestResult)
+ })
}
async function listUserExports (req: express.Request, res: express.Response) {
diff --git a/server/core/controllers/api/users/user-imports.ts b/server/core/controllers/api/users/user-imports.ts
index a89384aec9..4a4bee9f1d 100644
--- a/server/core/controllers/api/users/user-imports.ts
+++ b/server/core/controllers/api/users/user-imports.ts
@@ -1,15 +1,12 @@
import express from 'express'
-import {
- asyncMiddleware,
- authenticate
-} from '../../../middlewares/index.js'
+import { asyncMiddleware, authenticate } from '../../../middlewares/index.js'
import { setupUploadResumableRoutes } from '@server/lib/uploadx.js'
import {
getLatestImportStatusValidator,
userImportRequestResumableInitValidator,
userImportRequestResumableValidator
} from '@server/middlewares/validators/users/user-import.js'
-import { HttpStatusCode, UserImportState, UserImportUploadResult } from '@peertube/peertube-models'
+import { HttpStatusCode, UserImportState } from '@peertube/peertube-models'
import { logger } from '@server/helpers/logger.js'
import { UserImportModel } from '@server/models/user/user-import.js'
import { getFSUserImportFilePath } from '@server/lib/paths.js'
@@ -19,7 +16,8 @@ import { saveInTransactionWithRetries } from '@server/helpers/database-utils.js'
const userImportRouter = express.Router()
-userImportRouter.get('/:userId/imports/latest',
+userImportRouter.get(
+ '/:userId/imports/latest',
authenticate,
asyncMiddleware(getLatestImportStatusValidator),
asyncMiddleware(getLatestImport)
@@ -68,7 +66,7 @@ async function addUserImportResumable (req: express.Request, res: express.Respon
userImport: {
id: userImport.id
}
- } as UserImportUploadResult)
+ })
}
async function getLatestImport (req: express.Request, res: express.Response) {
diff --git a/server/core/controllers/api/video-playlist.ts b/server/core/controllers/api/video-playlist.ts
index 1dcd447692..64c1b901a8 100644
--- a/server/core/controllers/api/video-playlist.ts
+++ b/server/core/controllers/api/video-playlist.ts
@@ -3,9 +3,7 @@ import {
HttpStatusCode,
VideoChannelActivityAction,
VideoPlaylistCreate,
- VideoPlaylistCreateResult,
VideoPlaylistElementCreate,
- VideoPlaylistElementCreateResult,
VideoPlaylistElementUpdate,
VideoPlaylistPrivacy,
VideoPlaylistPrivacyType,
@@ -245,7 +243,7 @@ async function createVideoPlaylist (req: express.Request, res: express.Response)
id: videoPlaylistCreated.id,
shortUUID: uuidToShort(videoPlaylistCreated.uuid),
uuid: videoPlaylistCreated.uuid
- } as VideoPlaylistCreateResult
+ }
})
}
@@ -467,7 +465,7 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response)
return res.json({
videoPlaylistElement: {
id: playlistElement.id
- } as VideoPlaylistElementCreateResult
+ }
})
}
diff --git a/server/core/controllers/api/videos/comment.ts b/server/core/controllers/api/videos/comment.ts
index 3ad56e5636..18a49b8cd4 100644
--- a/server/core/controllers/api/videos/comment.ts
+++ b/server/core/controllers/api/videos/comment.ts
@@ -1,13 +1,5 @@
import { pick } from '@peertube/peertube-core-utils'
-import {
- HttpStatusCode,
- ResultList,
- ThreadsResultList,
- UserRight,
- VideoCommentCreate,
- VideoCommentPolicy,
- VideoCommentThreads
-} from '@peertube/peertube-models'
+import { HttpStatusCode, ResultList, ThreadsResultList, UserRight, VideoCommentCreate, VideoCommentPolicy } from '@peertube/peertube-models'
import { getServerActor } from '@server/models/application/application.js'
import { MCommentFormattable } from '@server/types/models/index.js'
import express from 'express'
@@ -183,7 +175,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) {
return res.json({
...getFormattedObjects(resultList.data, resultList.total),
totalNotDeletedComments: resultList.totalNotDeletedComments
- } as VideoCommentThreads)
+ })
}
async function listVideoThreadComments (req: express.Request, res: express.Response) {
diff --git a/server/core/controllers/api/videos/studio.ts b/server/core/controllers/api/videos/studio.ts
index 192cee3c39..d8c55a0cd2 100644
--- a/server/core/controllers/api/videos/studio.ts
+++ b/server/core/controllers/api/videos/studio.ts
@@ -151,7 +151,7 @@ async function buildWatermarkTask (task: VideoStudioTaskWatermark, indice: numbe
function buildRemoveSegmentsTask (task: VideoStudioTaskRemoveSegments) {
return Promise.resolve({
- name: task.name as 'remove-segments',
+ name: task.name,
options: {
segments: task.options.segments
}
diff --git a/server/core/helpers/core-utils.ts b/server/core/helpers/core-utils.ts
index 889fd22f40..2bdfdc33c7 100644
--- a/server/core/helpers/core-utils.ts
+++ b/server/core/helpers/core-utils.ts
@@ -186,8 +186,6 @@ function pageToStartAndCount (page: number, itemsPerPage: number) {
// ---------------------------------------------------------------------------
-type SemVersion = { major: number, minor: number, patch: number }
-
/**
* Parses a semantic version string into its separate components.
* Fairly lax, and allows for missing or additional segments in the string.
@@ -204,7 +202,7 @@ function parseSemVersion (s: string) {
major: parseInt(parsed[1]),
minor: parseInt(parsed[2]),
patch: parsed[3] ? parseInt(parsed[3]) : 0
- } as SemVersion
+ }
}
// ---------------------------------------------------------------------------
diff --git a/server/core/helpers/custom-validators/runners/jobs.ts b/server/core/helpers/custom-validators/runners/jobs.ts
index aa05b13423..e85e928e56 100644
--- a/server/core/helpers/custom-validators/runners/jobs.ts
+++ b/server/core/helpers/custom-validators/runners/jobs.ts
@@ -34,7 +34,7 @@ export function isRunnerJobSuccessPayloadValid (value: RunnerJobSuccessPayload,
return isRunnerJobVODWebVideoResultPayloadValid(value as VODWebVideoTranscodingSuccess, type, files) ||
isRunnerJobVODHLSResultPayloadValid(value as VODHLSTranscodingSuccess, type, files) ||
isRunnerJobVODAudioMergeResultPayloadValid(value as VODHLSTranscodingSuccess, type, files) ||
- isRunnerJobLiveRTMPHLSResultPayloadValid(value as LiveRTMPHLSTranscodingSuccess, type) ||
+ isRunnerJobLiveRTMPHLSResultPayloadValid(value, type) ||
isRunnerJobVideoStudioResultPayloadValid(value as VideoStudioTranscodingSuccess, type, files) ||
isRunnerJobTranscriptionResultPayloadValid(value as TranscriptionSuccess, type, files) ||
isRunnerJobGenerateStoryboardResultPayloadValid(value as GenerateStoryboardSuccess, type, files)
diff --git a/server/core/initializers/migrations/0870-remove-web-video-redundancy.ts b/server/core/initializers/migrations/0870-remove-web-video-redundancy.ts
index 9d2b0fc977..7ee4b3c5fd 100644
--- a/server/core/initializers/migrations/0870-remove-web-video-redundancy.ts
+++ b/server/core/initializers/migrations/0870-remove-web-video-redundancy.ts
@@ -18,7 +18,7 @@ async function up (utils: {
const rows = await utils.sequelize.query<{ videoFileId: number }>(query, {
transaction,
- type: QueryTypes.SELECT as QueryTypes.SELECT
+ type: QueryTypes.SELECT
})
for (const { videoFileId } of rows) {
@@ -63,5 +63,6 @@ function down (options) {
}
export {
- down, up
+ down,
+ up
}
diff --git a/server/core/initializers/migrations/0975-pkcs8.ts b/server/core/initializers/migrations/0975-pkcs8.ts
index 1aee608635..b994c37fca 100644
--- a/server/core/initializers/migrations/0975-pkcs8.ts
+++ b/server/core/initializers/migrations/0975-pkcs8.ts
@@ -9,7 +9,7 @@ async function up (utils: {
}): Promise<void> {
const rows = await utils.sequelize.query<{ id: number, privateKey: string }>(
'SELECT "id", "privateKey" FROM "actor" WHERE "serverId" IS NULL',
- { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT, transaction: utils.transaction }
+ { type: Sequelize.QueryTypes.SELECT, transaction: utils.transaction }
)
for (const { id, privateKey } of rows) {
diff --git a/server/core/initializers/migrations/1090-otp-secret-gcm.ts b/server/core/initializers/migrations/1090-otp-secret-gcm.ts
index f20822cc07..489502766d 100644
--- a/server/core/initializers/migrations/1090-otp-secret-gcm.ts
+++ b/server/core/initializers/migrations/1090-otp-secret-gcm.ts
@@ -15,7 +15,7 @@ async function up (utils: {
}): Promise<void> {
const rows = await utils.sequelize.query<{ id: number, otpSecret: string }>(
'SELECT "id", "otpSecret" FROM "user" WHERE "otpSecret" IS NOT NULL',
- { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT, transaction: utils.transaction }
+ { type: Sequelize.QueryTypes.SELECT, transaction: utils.transaction }
)
let removed = 0
diff --git a/server/core/lib/activitypub/process/process-update.ts b/server/core/lib/activitypub/process/process-update.ts
index ab4696cdbc..88c7992e2a 100644
--- a/server/core/lib/activitypub/process/process-update.ts
+++ b/server/core/lib/activitypub/process/process-update.ts
@@ -1,7 +1,6 @@
import { arrayify } from '@peertube/peertube-core-utils'
import {
ActivityPubActor,
- ActivityPubActorType,
ActivityUpdate,
ActivityUpdateObject,
CacheFileObject,
@@ -39,7 +38,7 @@ async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate
return retryTransactionWrapper(() => processUpdateVideo(byActor, activity as ActivityUpdate<VideoObject | string>))
}
- if (isActorTypeValid(objectType as ActivityPubActorType)) {
+ if (isActorTypeValid(objectType)) {
// An actor can only update itself: the object id must be the actor that signed the activity
const actorObjectId = getAPId(object as ActivityPubActor)
if (actorObjectId !== byActor.url) {
diff --git a/server/core/lib/activitypub/send/send-announce.ts b/server/core/lib/activitypub/send/send-announce.ts
index 06e599b428..44ddd6fead 100644
--- a/server/core/lib/activitypub/send/send-announce.ts
+++ b/server/core/lib/activitypub/send/send-announce.ts
@@ -46,7 +46,7 @@ export function buildAnnounceActivity (url: string, byActor: MActorLight, object
if (!audience) audience = getPublicAudience(byActor)
return audiencify({
- type: 'Announce' as 'Announce',
+ type: 'Announce',
id: url,
actor: byActor.url,
object
diff --git a/server/core/lib/activitypub/send/send-create.ts b/server/core/lib/activitypub/send/send-create.ts
index e29f12a372..a3400b0082 100644
--- a/server/core/lib/activitypub/send/send-create.ts
+++ b/server/core/lib/activitypub/send/send-create.ts
@@ -196,7 +196,7 @@ export function buildCreateActivity<T extends ActivityCreateObject> (
return audiencify(
{
- type: 'Create' as 'Create',
+ type: 'Create',
id: url + '/activity',
actor: byActor.url,
object: typeof object === 'string'
diff --git a/server/core/lib/activitypub/send/send-dislike.ts b/server/core/lib/activitypub/send/send-dislike.ts
index 6b08e37a49..081ab17cbf 100644
--- a/server/core/lib/activitypub/send/send-dislike.ts
+++ b/server/core/lib/activitypub/send/send-dislike.ts
@@ -24,7 +24,7 @@ function buildDislikeActivity (url: string, byActor: MActorAudience, video: MVid
return audiencify(
{
id: url,
- type: 'Dislike' as 'Dislike',
+ type: 'Dislike',
actor: byActor.url,
object: video.url
},
diff --git a/server/core/lib/activitypub/send/send-download.ts b/server/core/lib/activitypub/send/send-download.ts
index fc24f84b41..12e488fcae 100644
--- a/server/core/lib/activitypub/send/send-download.ts
+++ b/server/core/lib/activitypub/send/send-download.ts
@@ -61,7 +61,7 @@ function buildDownloadActivity (options: {
return audiencify({
id: url,
- type: 'Download' as 'Download',
+ type: 'Download',
actor: byActor.url,
object: video.url
}, audience)
diff --git a/server/core/lib/activitypub/send/send-like.ts b/server/core/lib/activitypub/send/send-like.ts
index 800c7066d4..7aea76985b 100644
--- a/server/core/lib/activitypub/send/send-like.ts
+++ b/server/core/lib/activitypub/send/send-like.ts
@@ -24,7 +24,7 @@ function buildLikeActivity (url: string, byActor: MActorAudience, video: MVideoU
return audiencify(
{
id: url,
- type: 'Like' as 'Like',
+ type: 'Like',
actor: byActor.url,
object: video.url
},
diff --git a/server/core/lib/activitypub/send/send-undo.ts b/server/core/lib/activitypub/send/send-undo.ts
index 237132dbef..d7fba91dc5 100644
--- a/server/core/lib/activitypub/send/send-undo.ts
+++ b/server/core/lib/activitypub/send/send-undo.ts
@@ -135,7 +135,7 @@ function undoActivityData<T extends ActivityUndoObject> (
return audiencify(
{
- type: 'Undo' as 'Undo',
+ type: 'Undo',
id: url,
actor: byActor.url,
object
diff --git a/server/core/lib/activitypub/send/send-update.ts b/server/core/lib/activitypub/send/send-update.ts
index 73a7bae8ed..3ae5558115 100644
--- a/server/core/lib/activitypub/send/send-update.ts
+++ b/server/core/lib/activitypub/send/send-update.ts
@@ -181,7 +181,7 @@ function buildUpdateActivity (
return audiencify(
{
- type: 'Update' as 'Update',
+ type: 'Update',
id: url,
actor: byActor.url,
object: audiencify(object, audience)
diff --git a/server/core/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/core/lib/activitypub/videos/shared/object-to-model-attributes.ts
index 0ee448ce94..c5454c8799 100644
--- a/server/core/lib/activitypub/videos/shared/object-to-model-attributes.ts
+++ b/server/core/lib/activitypub/videos/shared/object-to-model-attributes.ts
@@ -241,7 +241,7 @@ export function getCaptionAttributesFromObject (video: MVideoId, videoObject: Vi
m3u8Filename: VideoCaptionModel.generateM3U8Filename(filename),
m3u8Url: url.find(u => u.mediaType === 'application/x-mpegURL')?.href,
cached: false
- } as Partial<AttributesOnly<VideoCaptionModel>>
+ }
})
}
diff --git a/server/core/lib/html/shared/playlist-html.ts b/server/core/lib/html/shared/playlist-html.ts
index 9170d98b5e..154555a441 100644
--- a/server/core/lib/html/shared/playlist-html.ts
+++ b/server/core/lib/html/shared/playlist-html.ts
@@ -115,7 +115,7 @@ export class PlaylistHtml {
schemaType: 'ItemList',
ogType: addOG
- ? 'video' as 'video'
+ ? 'video'
: undefined,
twitterCard: addTwitterCard
diff --git a/server/core/lib/html/shared/video-html.ts b/server/core/lib/html/shared/video-html.ts
index 19d138e077..47f0515271 100644
--- a/server/core/lib/html/shared/video-html.ts
+++ b/server/core/lib/html/shared/video-html.ts
@@ -148,7 +148,7 @@ export class VideoHtml {
},
ogType: addOG
- ? 'video' as 'video'
+ ? 'video'
: undefined,
twitterCard: addTwitterCard
diff --git a/server/core/lib/local-video-creator.ts b/server/core/lib/local-video-creator.ts
index 3a4f629956..64e7bae2c0 100644
--- a/server/core/lib/local-video-creator.ts
+++ b/server/core/lib/local-video-creator.ts
@@ -136,7 +136,7 @@ export class LocalVideoCreator {
async create () {
this.video = new VideoModel(
await Hooks.wrapObject(this.buildVideo(this.videoAttributes, this.channel), this.videoAttributeResultHook)
- ) as MVideoFull
+ )
this.video.VideoChannel = this.channel
this.video.url = getLocalVideoActivityPubUrl(this.video)
diff --git a/server/core/lib/plugins/register-helpers.ts b/server/core/lib/plugins/register-helpers.ts
index 6d5acd68e2..d386ccf94d 100644
--- a/server/core/lib/plugins/register-helpers.ts
+++ b/server/core/lib/plugins/register-helpers.ts
@@ -15,7 +15,6 @@ import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-
import { PluginModel } from '@server/models/server/plugin.js'
import {
RegisterServerAuthExternalOptions,
- RegisterServerAuthExternalResult,
RegisterServerAuthPassOptions,
RegisterServerExternalAuthenticatedResult,
RegisterServerOptions,
@@ -270,7 +269,7 @@ export class RegisterHelpers {
logger.error('Cannot execute onExternalUserAuthenticated.', { npmName: self.npmName, authName: options.authName, err })
})
}
- } as RegisterServerAuthExternalResult
+ }
}
}
diff --git a/server/core/lib/transcoding/hls-transcoding.ts b/server/core/lib/transcoding/hls-transcoding.ts
index 746712e4d4..80017facb9 100644
--- a/server/core/lib/transcoding/hls-transcoding.ts
+++ b/server/core/lib/transcoding/hls-transcoding.ts
@@ -31,7 +31,7 @@ export async function generateHlsPlaylistResolutionFromTS (options: {
preventInputFileLocking?: boolean
}) {
return generateHlsPlaylistCommon({
- type: 'hls-from-ts' as 'hls-from-ts',
+ type: 'hls-from-ts',
videoInputPath: options.concatenatedTsFilePath,
@@ -55,7 +55,7 @@ export function generateHlsPlaylistResolution (options: {
abortSignal: AbortSignal
}) {
return generateHlsPlaylistCommon({
- type: 'hls' as 'hls',
+ type: 'hls',
...pick(options, [
'videoInputPath',
diff --git a/server/core/lib/user-import-export/exporters/auto-tag-policies.ts b/server/core/lib/user-import-export/exporters/auto-tag-policies.ts
index ded6eef8b5..6354d0d20b 100644
--- a/server/core/lib/user-import-export/exporters/auto-tag-policies.ts
+++ b/server/core/lib/user-import-export/exporters/auto-tag-policies.ts
@@ -2,15 +2,14 @@ import { AutoTagPoliciesJSON } from '@peertube/peertube-models'
import { AutomaticTagger } from '@server/lib/automatic-tags/automatic-tagger.js'
import { AbstractUserExporter } from './abstract-user-exporter.js'
-export class AutoTagPoliciesExporter extends AbstractUserExporter <AutoTagPoliciesJSON> {
-
+export class AutoTagPoliciesExporter extends AbstractUserExporter<AutoTagPoliciesJSON> {
async export () {
const data = await AutomaticTagger.getAutomaticTagPolicies(this.user.Account)
return {
json: {
reviewComments: data.review.map(name => ({ name }))
- } as AutoTagPoliciesJSON,
+ },
staticFiles: []
}
diff --git a/server/core/lib/user-import-export/exporters/blocklist-exporter.ts b/server/core/lib/user-import-export/exporters/blocklist-exporter.ts
index ebfbacbcf5..973097982a 100644
--- a/server/core/lib/user-import-export/exporters/blocklist-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/blocklist-exporter.ts
@@ -14,7 +14,7 @@ export class BlocklistExporter extends AbstractUserExporter<BlocklistExportJSON>
json: {
instances: instancesBlocklist.map(b => ({ host: b })),
actors: accountsBlocklist.map(h => ({ handle: h }))
- } as BlocklistExportJSON,
+ },
staticFiles: []
}
diff --git a/server/core/lib/user-import-export/exporters/dislikes-exporter.ts b/server/core/lib/user-import-export/exporters/dislikes-exporter.ts
index dea76693f8..ea9b860e18 100644
--- a/server/core/lib/user-import-export/exporters/dislikes-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/dislikes-exporter.ts
@@ -6,15 +6,14 @@ import { activityPubCollection } from '@server/lib/activitypub/collection.js'
import { getContextFilter } from '@server/lib/activitypub/context.js'
import { activityPubContextify } from '@server/helpers/activity-pub-utils.js'
-export class DislikesExporter extends AbstractUserExporter <DislikesExportJSON> {
-
+export class DislikesExporter extends AbstractUserExporter<DislikesExportJSON> {
async export () {
const dislikes = await AccountVideoRateModel.listRatesOfAccountIdForExport(this.user.Account.id, 'dislike')
return {
json: {
dislikes: this.formatDislikesJSON(dislikes)
- } as DislikesExportJSON,
+ },
activityPub: await this.formatDislikesAP(dislikes),
@@ -37,5 +36,4 @@ export class DislikesExporter extends AbstractUserExporter <DislikesExportJSON>
getContextFilter()
)
}
-
}
diff --git a/server/core/lib/user-import-export/exporters/followers-exporter.ts b/server/core/lib/user-import-export/exporters/followers-exporter.ts
index 9ff199086d..9082e18ea1 100644
--- a/server/core/lib/user-import-export/exporters/followers-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/followers-exporter.ts
@@ -22,7 +22,7 @@ export class FollowersExporter extends AbstractUserExporter<FollowersExportJSON>
}
return {
- json: { followers: followersJSON } as FollowersExportJSON,
+ json: { followers: followersJSON },
staticFiles: []
}
diff --git a/server/core/lib/user-import-export/exporters/following-exporter.ts b/server/core/lib/user-import-export/exporters/following-exporter.ts
index 871d617ba6..46f784dab2 100644
--- a/server/core/lib/user-import-export/exporters/following-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/following-exporter.ts
@@ -11,7 +11,7 @@ export class FollowingExporter extends AbstractUserExporter<FollowingExportJSON>
const followingJSON = this.formatFollowingJSON(following, this.user.Account.Actor.getFullIdentifier())
return {
- json: { following: followingJSON } as FollowingExportJSON,
+ json: { following: followingJSON },
staticFiles: [],
diff --git a/server/core/lib/user-import-export/exporters/likes-exporter.ts b/server/core/lib/user-import-export/exporters/likes-exporter.ts
index dcb9565fe5..c39bf99178 100644
--- a/server/core/lib/user-import-export/exporters/likes-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/likes-exporter.ts
@@ -6,15 +6,14 @@ import { activityPubCollection } from '@server/lib/activitypub/collection.js'
import { activityPubContextify } from '@server/helpers/activity-pub-utils.js'
import { getContextFilter } from '@server/lib/activitypub/context.js'
-export class LikesExporter extends AbstractUserExporter <LikesExportJSON> {
-
+export class LikesExporter extends AbstractUserExporter<LikesExportJSON> {
async export () {
const likes = await AccountVideoRateModel.listRatesOfAccountIdForExport(this.user.Account.id, 'like')
return {
json: {
likes: this.formatLikesJSON(likes)
- } as LikesExportJSON,
+ },
activityPub: await this.formatLikesAP(likes),
diff --git a/server/core/lib/user-import-export/exporters/user-video-history-exporter.ts b/server/core/lib/user-import-export/exporters/user-video-history-exporter.ts
index cff59ae622..62db241069 100644
--- a/server/core/lib/user-import-export/exporters/user-video-history-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/user-video-history-exporter.ts
@@ -2,8 +2,7 @@ import { UserVideoHistoryExportJSON } from '@peertube/peertube-models'
import { AbstractUserExporter } from './abstract-user-exporter.js'
import { UserVideoHistoryModel } from '@server/models/user/user-video-history.js'
-export class UserVideoHistoryExporter extends AbstractUserExporter <UserVideoHistoryExportJSON> {
-
+export class UserVideoHistoryExporter extends AbstractUserExporter<UserVideoHistoryExportJSON> {
async export () {
const videos = await UserVideoHistoryModel.listForExport(this.user)
@@ -15,7 +14,7 @@ export class UserVideoHistoryExporter extends AbstractUserExporter <UserVideoHis
createdAt: v.createdAt.toISOString(),
updatedAt: v.updatedAt.toISOString()
}))
- } as UserVideoHistoryExportJSON,
+ },
staticFiles: []
}
diff --git a/server/core/lib/user-import-export/exporters/videos-exporter.ts b/server/core/lib/user-import-export/exporters/videos-exporter.ts
index 6b2e09c0fc..dc083901e4 100644
--- a/server/core/lib/user-import-export/exporters/videos-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/videos-exporter.ts
@@ -349,7 +349,7 @@ export class VideosExporter extends AbstractUserExporter<VideoExportJSON> {
attachment: this.options.withVideoFiles && exportedVideoFileOrSource
? [
{
- type: 'Video' as 'Video',
+ type: 'Video',
url: join(this.options.relativeStaticDirPath, this.getArchiveVideoFilePath(video, exportedVideoFileOrSource)),
// FIXME: typings
diff --git a/server/core/lib/user-import-export/exporters/watched-words-lists-exporter.ts b/server/core/lib/user-import-export/exporters/watched-words-lists-exporter.ts
index 4bb5c0ec86..d99df30527 100644
--- a/server/core/lib/user-import-export/exporters/watched-words-lists-exporter.ts
+++ b/server/core/lib/user-import-export/exporters/watched-words-lists-exporter.ts
@@ -2,8 +2,7 @@ import { WatchedWordsListsJSON } from '@peertube/peertube-models'
import { WatchedWordsListModel } from '@server/models/watched-words/watched-words-list.js'
import { AbstractUserExporter } from './abstract-user-exporter.js'
-export class WatchedWordsListsExporter extends AbstractUserExporter <WatchedWordsListsJSON> {
-
+export class WatchedWordsListsExporter extends AbstractUserExporter<WatchedWordsListsJSON> {
async export () {
const data = await WatchedWordsListModel.listForExport({ accountId: this.user.Account.id })
@@ -15,7 +14,7 @@ export class WatchedWordsListsExporter extends AbstractUserExporter <WatchedWord
createdAt: list.createdAt.toISOString(),
updatedAt: list.updatedAt.toISOString()
}))
- } as WatchedWordsListsJSON,
+ },
staticFiles: []
}
diff --git a/server/core/middlewares/cache/shared/api-cache.ts b/server/core/middlewares/cache/shared/api-cache.ts
index 443e2c7ae4..5edca0512e 100644
--- a/server/core/middlewares/cache/shared/api-cache.ts
+++ b/server/core/middlewares/cache/shared/api-cache.ts
@@ -133,7 +133,7 @@ export class ApiCache {
// Seconds since epoch, used to properly decrement max-age headers in cached responses.
timestamp: new Date().getTime() / 1000
- } as CacheObject
+ }
}
private async cacheResponse (key: string, value: object, duration: number) {
diff --git a/server/core/middlewares/validators/shared/videos.ts b/server/core/middlewares/validators/shared/videos.ts
index 5782362f17..9edd2e984d 100644
--- a/server/core/middlewares/validators/shared/videos.ts
+++ b/server/core/middlewares/validators/shared/videos.ts
@@ -59,7 +59,7 @@ export async function doesVideoExist (id: number | string, res: Response, fetchT
case 'none':
case 'id':
- res.locals.videoId = video as MVideoId
+ res.locals.videoId = video
break
case 'with-blacklist':
diff --git a/server/core/models/abuse/abuse.ts b/server/core/models/abuse/abuse.ts
index 339d4f6d8e..72680dbed5 100644
--- a/server/core/models/abuse/abuse.ts
+++ b/server/core/models/abuse/abuse.ts
@@ -40,11 +40,11 @@ import {
MAbuseUserFormattable,
MUserAccountId
} from '../../types/models/index.js'
-import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account.js'
+import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account.js'
import { SequelizeModel, getSort, parseAggregateResult, throwIfNotValid } from '../shared/index.js'
import { ThumbnailModel, thumbnailAPIAttributes } from '../video/thumbnail.js'
import { VideoBlacklistModel } from '../video/video-blacklist.js'
-import { SummaryOptions as ChannelSummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel.js'
+import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel.js'
import { ScopeNames as CommentScopeNames, VideoCommentModel } from '../video/video-comment.js'
import { VideoModel, ScopeNames as VideoScopeNames } from '../video/video.js'
import { BuildAbusesQueryOptions, buildAbuseListQuery } from './sql/abuse-query-builder.js'
@@ -123,7 +123,7 @@ export enum ScopeNames {
model: AccountModel.scope({
method: [
AccountScopeNames.SUMMARY,
- { actorRequired: false } as AccountSummaryOptions
+ { actorRequired: false }
]
}),
as: 'ReporterAccount'
@@ -132,7 +132,7 @@ export enum ScopeNames {
model: AccountModel.scope({
method: [
AccountScopeNames.SUMMARY,
- { actorRequired: false } as AccountSummaryOptions
+ { actorRequired: false }
]
}),
as: 'FlaggedAccount'
@@ -166,7 +166,7 @@ export enum ScopeNames {
model: VideoChannelModel.scope({
method: [
VideoChannelScopeNames.SUMMARY,
- { withAccount: false, actorRequired: false } as ChannelSummaryOptions
+ { withAccount: false, actorRequired: false }
]
}),
required: false
@@ -606,7 +606,7 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
const endAt = this.VideoAbuse?.endAt
return {
- type: 'Flag' as 'Flag',
+ type: 'Flag',
content: this.reason,
mediaType: 'text/markdown',
object,
diff --git a/server/core/models/account/account-video-rate.ts b/server/core/models/account/account-video-rate.ts
index 527cc78722..6b3a06a3f4 100644
--- a/server/core/models/account/account-video-rate.ts
+++ b/server/core/models/account/account-video-rate.ts
@@ -12,7 +12,7 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp
import { CONSTRAINTS_FIELDS, USER_EXPORT_MAX_ITEMS, VIDEO_RATE_TYPES } from '../../initializers/constants.js'
import { ActorModel } from '../actor/actor.js'
import { SequelizeModel, getSort, throwIfNotValid } from '../shared/index.js'
-import { SummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel.js'
+import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel.js'
import { VideoModel } from '../video/video.js'
import { AccountModel } from './account.js'
@@ -191,7 +191,7 @@ export class AccountVideoRateModel extends SequelizeModel<AccountVideoRateModel>
required: true,
include: [
{
- model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
+ model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } ] }),
required: true
}
]
diff --git a/server/core/models/blocklist/account-blocklist.ts b/server/core/models/blocklist/account-blocklist.ts
index 8abeb8264a..60043b2530 100644
--- a/server/core/models/blocklist/account-blocklist.ts
+++ b/server/core/models/blocklist/account-blocklist.ts
@@ -266,7 +266,7 @@ export class AccountBlocklistModel extends SequelizeModel<AccountBlocklistModel>
`AND (${handlesWhere.join(' OR ')})`
return AccountBlocklistModel.sequelize.query(rawQuery, {
- type: QueryTypes.SELECT as QueryTypes.SELECT,
+ type: QueryTypes.SELECT,
replacements: { byAccountIds, localHandles, remoteHandles }
})
}
diff --git a/server/core/models/blocklist/server-blocklist.ts b/server/core/models/blocklist/server-blocklist.ts
index bf56630b25..d1ad983331 100644
--- a/server/core/models/blocklist/server-blocklist.ts
+++ b/server/core/models/blocklist/server-blocklist.ts
@@ -153,7 +153,7 @@ export class ServerBlocklistModel extends SequelizeModel<ServerBlocklistModel> {
`AND "serverBlocklist"."accountId" IN (${createSafeIn(ServerBlocklistModel.sequelize, byAccountIds)})`
return ServerBlocklistModel.sequelize.query(rawQuery, {
- type: QueryTypes.SELECT as QueryTypes.SELECT,
+ type: QueryTypes.SELECT,
replacements: { hosts }
})
}
diff --git a/server/core/models/oauth/oauth-token.ts b/server/core/models/oauth/oauth-token.ts
index d69d54daaf..51a5c31808 100644
--- a/server/core/models/oauth/oauth-token.ts
+++ b/server/core/models/oauth/oauth-token.ts
@@ -188,7 +188,7 @@ export class OAuthTokenModel extends SequelizeModel<OAuthTokenModel> {
},
user: token.User,
token
- } as OAuthTokenInfo
+ }
})
.catch(err => {
logger.error('getRefreshToken error.', { err })
diff --git a/server/core/models/redundancy/video-redundancy.ts b/server/core/models/redundancy/video-redundancy.ts
index 4825b7cd12..c2f5f066bb 100644
--- a/server/core/models/redundancy/video-redundancy.ts
+++ b/server/core/models/redundancy/video-redundancy.ts
@@ -552,7 +552,7 @@ export class VideoRedundancyModel extends SequelizeModel<VideoRedundancyModel> {
toActivityPubObject (this: MVideoRedundancyAP): CacheFileObject {
return {
id: this.url,
- type: 'CacheFile' as 'CacheFile',
+ type: 'CacheFile',
object: this.VideoStreamingPlaylist.Video.url,
expires: this.expiresOn ? this.expiresOn.toISOString() : null,
url: {
diff --git a/server/core/models/stat/local-video-viewer.ts b/server/core/models/stat/local-video-viewer.ts
index 3357bd9578..e1120a8d0c 100644
--- a/server/core/models/stat/local-video-viewer.ts
+++ b/server/core/models/stat/local-video-viewer.ts
@@ -392,7 +392,7 @@ export class LocalVideoViewerModel extends SequelizeModel<LocalVideoViewerModel>
}
const queryOptions: QueryOptionsWithType<QueryTypes.SELECT> = {
- type: QueryTypes.SELECT as QueryTypes.SELECT,
+ type: QueryTypes.SELECT,
replacements: { videoId, startDate, endDate }
}
diff --git a/server/core/models/video/formatter/video-activity-pub-format.ts b/server/core/models/video/formatter/video-activity-pub-format.ts
index 39706e4aad..e53babfed5 100644
--- a/server/core/models/video/formatter/video-activity-pub-format.ts
+++ b/server/core/models/video/formatter/video-activity-pub-format.ts
@@ -49,13 +49,13 @@ export function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
type: 'Link',
mediaType: 'text/html',
href: WEBSERVER.URL + video.getWatchStaticPath()
- } as ActivityUrlObject,
+ },
{
type: 'Link',
mediaType: 'text/html',
href: video.url
- } as ActivityUrlObject,
+ },
...buildVideoFileUrls({ video, files: video.VideoFiles }),
@@ -65,7 +65,7 @@ export function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
]
return {
- type: 'Video' as 'Video',
+ type: 'Video',
id: video.url,
name: video.name,
duration: getActivityStreamDuration(video.duration),
@@ -310,19 +310,15 @@ function buildTags (video: MVideoAP): (ActivitySensitiveTagObject | ActivityHash
: []
return [
- ...tags.map(t =>
- ({
- type: 'Hashtag' as 'Hashtag',
- name: t.name
- }) as ActivityHashTagObject
- ),
-
- ...nsfwFlagsToString(video.nsfwFlags).map(f =>
- ({
- type: 'SensitiveTag' as 'SensitiveTag',
- name: f
- }) as ActivitySensitiveTagObject
- )
+ ...tags.map((t): ActivityHashTagObject => ({
+ type: 'Hashtag',
+ name: t.name
+ })),
+
+ ...nsfwFlagsToString(video.nsfwFlags).map((f): ActivitySensitiveTagObject => ({
+ type: 'SensitiveTag',
+ name: f
+ }))
]
}
diff --git a/server/core/models/video/video-blacklist.ts b/server/core/models/video/video-blacklist.ts
index dd4ac9dc83..e0fa4bddb9 100644
--- a/server/core/models/video/video-blacklist.ts
+++ b/server/core/models/video/video-blacklist.ts
@@ -2,11 +2,15 @@ import { VideoBlacklist, type VideoBlacklistType_Type } from '@peertube/peertube
import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/models/index.js'
import { FindOptions } from 'sequelize'
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Table, UpdatedAt } from 'sequelize-typescript'
-import { isVideoBlacklistReasonValid, isVideoBlacklistInternalNoteValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist.js'
+import {
+ isVideoBlacklistReasonValid,
+ isVideoBlacklistInternalNoteValid,
+ isVideoBlacklistTypeValid
+} from '../../helpers/custom-validators/video-blacklist.js'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js'
import { getBlacklistSort, searchAttribute, SequelizeModel, throwIfNotValid } from '../shared/index.js'
import { thumbnailAPIAttributes, ThumbnailModel } from './thumbnail.js'
-import { SummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js'
+import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js'
import { VideoModel } from './video.js'
@Table({
@@ -84,7 +88,7 @@ export class VideoBlacklistModel extends SequelizeModel<VideoBlacklistModel> {
where: searchAttribute(search, 'name'),
include: [
{
- model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
+ model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } ] }),
required: true
},
{
diff --git a/server/core/models/video/video-channel.ts b/server/core/models/video/video-channel.ts
index 0f4a0c3c3a..e85479724e 100644
--- a/server/core/models/video/video-channel.ts
+++ b/server/core/models/video/video-channel.ts
@@ -43,7 +43,7 @@ import {
MChannelSummaryFormattable,
type MChannel
} from '../../types/models/video/index.js'
-import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account.js'
+import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/account.js'
import { ActorImageModel } from '../actor/actor-image.js'
import { ActorModel, actorSummaryAttributes } from '../actor/actor.js'
import { ServerModel, serverSummaryAttributes } from '../server/server.js'
@@ -106,7 +106,7 @@ export type SummaryOptions = {
if (options.withAccount === true) {
include.push({
model: AccountModel.scope({
- method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ]
+ method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } ]
}),
required: true
})
diff --git a/server/core/models/video/video-playlist.ts b/server/core/models/video/video-playlist.ts
index 8d636f59b7..f18758e6b0 100644
--- a/server/core/models/video/video-playlist.ts
+++ b/server/core/models/video/video-playlist.ts
@@ -796,13 +796,13 @@ export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
return activityPubCollectionPagination(this.url, handler, page)
.then(o => {
return Object.assign(o, {
- type: 'Playlist' as 'Playlist',
+ type: 'Playlist' as const,
audience: this.VideoChannel?.Actor.url,
name: this.name,
content: this.description,
- mediaType: 'text/markdown' as 'text/markdown',
+ mediaType: 'text/markdown' as const,
uuid: this.uuid,
videoChannelPosition: this.videoChannelPosition,
published: this.createdAt.toISOString(),
diff --git a/server/core/models/video/video.ts b/server/core/models/video/video.ts
index 9cc525476c..9cf1e57fdc 100644
--- a/server/core/models/video/video.ts
+++ b/server/core/models/video/video.ts
@@ -158,7 +158,7 @@ import { TagModel } from './tag.js'
import { ThumbnailModel, thumbnailAPIAttributes } from './thumbnail.js'
import { VideoBlacklistModel } from './video-blacklist.js'
import { VideoCaptionModel } from './video-caption.js'
-import { SummaryOptions, VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js'
+import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel.js'
import { VideoCommentModel } from './video-comment.js'
import { VideoFileModel } from './video-file.js'
import { VideoImportModel } from './video-import.js'
@@ -219,7 +219,7 @@ export type ForAPIOptions = {
{
withAccount: true,
withAccountBlockerIds: options.withAccountBlockerIds
- } as SummaryOptions
+ }
]
}),
required: true
diff --git a/server/scripts/migrations/peertube-6.3.ts b/server/scripts/migrations/peertube-6.3.ts
index 9077fd4582..ad78ac7065 100644
--- a/server/scripts/migrations/peertube-6.3.ts
+++ b/server/scripts/migrations/peertube-6.3.ts
@@ -23,7 +23,7 @@ async function run () {
console.log('## Updating "formatFlags" column for web videos in "videoFile" table in database ##\n')
const totalQuery = 'SELECT COUNT(*) AS "total" FROM "videoFile" WHERE "videoId" IS NOT NULL AND "formatFlags" != 1'
- const res = await sequelizeTypescript.query<{ total: string }>(totalQuery, { type: QueryTypes.SELECT as QueryTypes.SELECT })
+ const res = await sequelizeTypescript.query<{ total: string }>(totalQuery, { type: QueryTypes.SELECT })
const total = parseInt(res[0].total)
console.log(`Will update ${total.toLocaleString()} rows`)
@@ -40,7 +40,7 @@ async function run () {
await sequelizeTypescript.query(
'UPDATE "videoFile" SET "formatFlags" = 1 WHERE id IN (' +
'SELECT id FROM "videoFile" WHERE "videoId" IS NOT NULL AND "formatFlags" != 1 LIMIT ' + chunkSize +
- ')'
+ ')'
)
remaining -= chunkSize