diff options
Diffstat (limited to 'server')
28 files changed, 48 insertions, 47 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index 3b8fb34a8..c5edf86b7 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -56,9 +56,9 @@ function inboxController (req: express.Request, res: express.Response) { | |||
56 | const rootActivity: RootActivity = req.body | 56 | const rootActivity: RootActivity = req.body |
57 | let activities: Activity[] | 57 | let activities: Activity[] |
58 | 58 | ||
59 | if ([ 'Collection', 'CollectionPage' ].indexOf(rootActivity.type) !== -1) { | 59 | if ([ 'Collection', 'CollectionPage' ].includes(rootActivity.type)) { |
60 | activities = (rootActivity as ActivityPubCollection).items | 60 | activities = (rootActivity as ActivityPubCollection).items |
61 | } else if ([ 'OrderedCollection', 'OrderedCollectionPage' ].indexOf(rootActivity.type) !== -1) { | 61 | } else if ([ 'OrderedCollection', 'OrderedCollectionPage' ].includes(rootActivity.type)) { |
62 | activities = (rootActivity as ActivityPubOrderedCollection<Activity>).orderedItems | 62 | activities = (rootActivity as ActivityPubOrderedCollection<Activity>).orderedItems |
63 | } else { | 63 | } else { |
64 | activities = [ rootActivity as Activity ] | 64 | activities = [ rootActivity as Activity ] |
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index 349650aca..16ffbf683 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts | |||
@@ -60,7 +60,7 @@ function searchVideoChannels (req: express.Request, res: express.Response) { | |||
60 | 60 | ||
61 | // Handle strings like @toto@example.com | 61 | // Handle strings like @toto@example.com |
62 | if (parts.length === 3 && parts[0].length === 0) parts.shift() | 62 | if (parts.length === 3 && parts[0].length === 0) parts.shift() |
63 | const isWebfingerSearch = parts.length === 2 && parts.every(p => p && p.indexOf(' ') === -1) | 63 | const isWebfingerSearch = parts.length === 2 && parts.every(p => p && !p.includes(' ')) |
64 | 64 | ||
65 | if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res) | 65 | if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res) |
66 | 66 | ||
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 20689fb58..08c0f1fa6 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -76,7 +76,7 @@ function serveServerTranslations (req: express.Request, res: express.Response) { | |||
76 | const locale = req.params.locale | 76 | const locale = req.params.locale |
77 | const file = req.params.file | 77 | const file = req.params.file |
78 | 78 | ||
79 | if (is18nLocale(locale) && LOCALE_FILES.indexOf(file) !== -1) { | 79 | if (is18nLocale(locale) && LOCALE_FILES.includes(file)) { |
80 | const completeLocale = getCompleteLocale(locale) | 80 | const completeLocale = getCompleteLocale(locale) |
81 | const completeFileLocale = buildFileLocale(completeLocale) | 81 | const completeFileLocale = buildFileLocale(completeLocale) |
82 | 82 | ||
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index fec67823d..2f44522a5 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts | |||
@@ -28,7 +28,7 @@ function isActorPublicKeyValid (publicKey: string) { | |||
28 | return exists(publicKey) && | 28 | return exists(publicKey) && |
29 | typeof publicKey === 'string' && | 29 | typeof publicKey === 'string' && |
30 | publicKey.startsWith('-----BEGIN PUBLIC KEY-----') && | 30 | publicKey.startsWith('-----BEGIN PUBLIC KEY-----') && |
31 | publicKey.indexOf('-----END PUBLIC KEY-----') !== -1 && | 31 | publicKey.includes('-----END PUBLIC KEY-----') && |
32 | validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY) | 32 | validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY) |
33 | } | 33 | } |
34 | 34 | ||
@@ -43,7 +43,7 @@ function isActorPrivateKeyValid (privateKey: string) { | |||
43 | typeof privateKey === 'string' && | 43 | typeof privateKey === 'string' && |
44 | privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') && | 44 | privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') && |
45 | // Sometimes there is a \n at the end, so just assert the string contains the end mark | 45 | // Sometimes there is a \n at the end, so just assert the string contains the end mark |
46 | privateKey.indexOf('-----END RSA PRIVATE KEY-----') !== -1 && | 46 | privateKey.includes('-----END RSA PRIVATE KEY-----') && |
47 | validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) | 47 | validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) |
48 | } | 48 | } |
49 | 49 | ||
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index 22b5e14a2..af8c8a0c8 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -84,19 +84,19 @@ function sanitizeAndCheckVideoTorrentObject (video: any) { | |||
84 | function isRemoteVideoUrlValid (url: any) { | 84 | function isRemoteVideoUrlValid (url: any) { |
85 | return url.type === 'Link' && | 85 | return url.type === 'Link' && |
86 | ( | 86 | ( |
87 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mediaType) !== -1 && | 87 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.includes(url.mediaType) && |
88 | isActivityPubUrlValid(url.href) && | 88 | isActivityPubUrlValid(url.href) && |
89 | validator.isInt(url.height + '', { min: 0 }) && | 89 | validator.isInt(url.height + '', { min: 0 }) && |
90 | validator.isInt(url.size + '', { min: 0 }) && | 90 | validator.isInt(url.size + '', { min: 0 }) && |
91 | (!url.fps || validator.isInt(url.fps + '', { min: -1 })) | 91 | (!url.fps || validator.isInt(url.fps + '', { min: -1 })) |
92 | ) || | 92 | ) || |
93 | ( | 93 | ( |
94 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mediaType) !== -1 && | 94 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.includes(url.mediaType) && |
95 | isActivityPubUrlValid(url.href) && | 95 | isActivityPubUrlValid(url.href) && |
96 | validator.isInt(url.height + '', { min: 0 }) | 96 | validator.isInt(url.height + '', { min: 0 }) |
97 | ) || | 97 | ) || |
98 | ( | 98 | ( |
99 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mediaType) !== -1 && | 99 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.includes(url.mediaType) && |
100 | validator.isLength(url.href, { min: 5 }) && | 100 | validator.isLength(url.href, { min: 5 }) && |
101 | validator.isInt(url.height + '', { min: 0 }) | 101 | validator.isInt(url.height + '', { min: 0 }) |
102 | ) || | 102 | ) || |
diff --git a/server/helpers/custom-validators/feeds.ts b/server/helpers/custom-validators/feeds.ts index 638e814f0..fa35a7da6 100644 --- a/server/helpers/custom-validators/feeds.ts +++ b/server/helpers/custom-validators/feeds.ts | |||
@@ -13,7 +13,7 @@ function isValidRSSFeed (value: string) { | |||
13 | 'atom1' | 13 | 'atom1' |
14 | ] | 14 | ] |
15 | 15 | ||
16 | return feedExtensions.indexOf(value) !== -1 | 16 | return feedExtensions.includes(value) |
17 | } | 17 | } |
18 | 18 | ||
19 | // --------------------------------------------------------------------------- | 19 | // --------------------------------------------------------------------------- |
diff --git a/server/helpers/custom-validators/logs.ts b/server/helpers/custom-validators/logs.ts index 30d0ce262..0f266ed3b 100644 --- a/server/helpers/custom-validators/logs.ts +++ b/server/helpers/custom-validators/logs.ts | |||
@@ -4,7 +4,7 @@ import { LogLevel } from '../../../shared/models/server/log-level.type' | |||
4 | const logLevels: LogLevel[] = [ 'debug', 'info', 'warn', 'error' ] | 4 | const logLevels: LogLevel[] = [ 'debug', 'info', 'warn', 'error' ] |
5 | 5 | ||
6 | function isValidLogLevel (value: any) { | 6 | function isValidLogLevel (value: any) { |
7 | return exists(value) && logLevels.indexOf(value) !== -1 | 7 | return exists(value) && logLevels.includes(value) |
8 | } | 8 | } |
9 | 9 | ||
10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 1ddbe0815..d6e91ad35 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -46,7 +46,7 @@ function isUserEmailVerifiedValid (value: any) { | |||
46 | 46 | ||
47 | const nsfwPolicies = values(NSFW_POLICY_TYPES) | 47 | const nsfwPolicies = values(NSFW_POLICY_TYPES) |
48 | function isUserNSFWPolicyValid (value: any) { | 48 | function isUserNSFWPolicyValid (value: any) { |
49 | return exists(value) && nsfwPolicies.indexOf(value) !== -1 | 49 | return exists(value) && nsfwPolicies.includes(value) |
50 | } | 50 | } |
51 | 51 | ||
52 | function isUserWebTorrentEnabledValid (value: any) { | 52 | function isUserWebTorrentEnabledValid (value: any) { |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index cfb430c63..60e8075f6 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -73,7 +73,7 @@ function isVideoViewsValid (value: string) { | |||
73 | } | 73 | } |
74 | 74 | ||
75 | function isVideoRatingTypeValid (value: string) { | 75 | function isVideoRatingTypeValid (value: string) { |
76 | return value === 'none' || values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1 | 76 | return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType) |
77 | } | 77 | } |
78 | 78 | ||
79 | function isVideoFileExtnameValid (value: string) { | 79 | function isVideoFileExtnameValid (value: string) { |
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index fc9d416a1..26dbe6543 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts | |||
@@ -257,7 +257,7 @@ function getTags (tags: any) { | |||
257 | function getLicence (licence: string) { | 257 | function getLicence (licence: string) { |
258 | if (!licence) return undefined | 258 | if (!licence) return undefined |
259 | 259 | ||
260 | if (licence.indexOf('Creative Commons Attribution') !== -1) return 1 | 260 | if (licence.includes('Creative Commons Attribution')) return 1 |
261 | 261 | ||
262 | return undefined | 262 | return undefined |
263 | } | 263 | } |
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index e01609eef..bc4aae957 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -54,7 +54,7 @@ function checkConfig () { | |||
54 | const defaultNSFWPolicy = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY | 54 | const defaultNSFWPolicy = CONFIG.INSTANCE.DEFAULT_NSFW_POLICY |
55 | { | 55 | { |
56 | const available = [ 'do_not_list', 'blur', 'display' ] | 56 | const available = [ 'do_not_list', 'blur', 'display' ] |
57 | if (available.indexOf(defaultNSFWPolicy) === -1) { | 57 | if (available.includes(defaultNSFWPolicy) === false) { |
58 | return 'NSFW policy setting should be ' + available.join(' or ') + ' instead of ' + defaultNSFWPolicy | 58 | return 'NSFW policy setting should be ' + available.join(' or ') + ' instead of ' + defaultNSFWPolicy |
59 | } | 59 | } |
60 | } | 60 | } |
@@ -64,7 +64,7 @@ function checkConfig () { | |||
64 | if (isArray(redundancyVideos)) { | 64 | if (isArray(redundancyVideos)) { |
65 | const available = [ 'most-views', 'trending', 'recently-added' ] | 65 | const available = [ 'most-views', 'trending', 'recently-added' ] |
66 | for (const r of redundancyVideos) { | 66 | for (const r of redundancyVideos) { |
67 | if (available.indexOf(r.strategy) === -1) { | 67 | if (available.includes(r.strategy) === false) { |
68 | return 'Videos redundancy should have ' + available.join(' or ') + ' strategy instead of ' + r.strategy | 68 | return 'Videos redundancy should have ' + available.join(' or ') + ' strategy instead of ' + r.strategy |
69 | } | 69 | } |
70 | 70 | ||
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 950ca61bd..3c07624e8 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -335,7 +335,7 @@ export function reloadConfig () { | |||
335 | 335 | ||
336 | function purge () { | 336 | function purge () { |
337 | for (const fileName in require.cache) { | 337 | for (const fileName in require.cache) { |
338 | if (fileName.indexOf(directory()) === -1) { | 338 | if (fileName.includes(directory()) === false) { |
339 | continue | 339 | continue |
340 | } | 340 | } |
341 | 341 | ||
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts index b8e9bd6d0..883224cb0 100644 --- a/server/initializers/migrations/0080-video-channels.ts +++ b/server/initializers/migrations/0080-video-channels.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as uuidv4 from 'uuid/v4' | 2 | import { v4 as uuidv4 } from 'uuid' |
3 | 3 | ||
4 | async function up (utils: { | 4 | async function up (utils: { |
5 | transaction: Sequelize.Transaction | 5 | transaction: Sequelize.Transaction |
diff --git a/server/initializers/migrations/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.ts index 76813f93f..89a14a6ee 100644 --- a/server/initializers/migrations/0345-video-playlists.ts +++ b/server/initializers/migrations/0345-video-playlists.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' | 2 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' |
3 | import * as uuidv4 from 'uuid/v4' | 3 | import { v4 as uuidv4 } from 'uuid' |
4 | import { WEBSERVER } from '../constants' | 4 | import { WEBSERVER } from '../constants' |
5 | 5 | ||
6 | async function up (utils: { | 6 | async function up (utils: { |
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 9eabef4b0..c3598b75b 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { Transaction } from 'sequelize' | 2 | import { Transaction } from 'sequelize' |
3 | import { URL } from 'url' | 3 | import { URL } from 'url' |
4 | import * as uuidv4 from 'uuid/v4' | 4 | import { v4 as uuidv4 } from 'uuid' |
5 | import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub' | 5 | import { ActivityPubActor, ActivityPubActorType, ActivityPubOrderedCollection } from '../../../shared/models/activitypub' |
6 | import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' | 6 | import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' |
7 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' | 7 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' |
8 | import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor' | 8 | import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor' |
@@ -207,7 +207,7 @@ async function fetchActorTotalItems (url: string) { | |||
207 | } | 207 | } |
208 | 208 | ||
209 | try { | 209 | try { |
210 | const { body } = await doRequest(options) | 210 | const { body } = await doRequest<ActivityPubOrderedCollection<unknown>>(options) |
211 | return body.totalItems ? body.totalItems : 0 | 211 | return body.totalItems ? body.totalItems : 0 |
212 | } catch (err) { | 212 | } catch (err) { |
213 | logger.warn('Cannot fetch remote actor count %s.', url, { err }) | 213 | logger.warn('Cannot fetch remote actor count %s.', url, { err }) |
diff --git a/server/lib/activitypub/playlist.ts b/server/lib/activitypub/playlist.ts index c52b715ef..c1d932a68 100644 --- a/server/lib/activitypub/playlist.ts +++ b/server/lib/activitypub/playlist.ts | |||
@@ -20,7 +20,9 @@ import { MAccountDefault, MAccountId, MVideoId } from '../../typings/models' | |||
20 | import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist' | 20 | import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist' |
21 | 21 | ||
22 | function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: MAccountId, to: string[]) { | 22 | function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: MAccountId, to: string[]) { |
23 | const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED | 23 | const privacy = to.includes(ACTIVITY_PUB.PUBLIC) |
24 | ? VideoPlaylistPrivacy.PUBLIC | ||
25 | : VideoPlaylistPrivacy.UNLISTED | ||
24 | 26 | ||
25 | return { | 27 | return { |
26 | name: playlistObject.name, | 28 | name: playlistObject.name, |
@@ -205,7 +207,7 @@ async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusC | |||
205 | 207 | ||
206 | logger.info('Fetching remote playlist %s.', playlistUrl) | 208 | logger.info('Fetching remote playlist %s.', playlistUrl) |
207 | 209 | ||
208 | const { response, body } = await doRequest(options) | 210 | const { response, body } = await doRequest<any>(options) |
209 | 211 | ||
210 | if (isPlaylistObjectValid(body) === false || checkUrlsSameHost(body.id, playlistUrl) !== true) { | 212 | if (isPlaylistObjectValid(body) === false || checkUrlsSameHost(body.id, playlistUrl) !== true) { |
211 | logger.debug('Remote video playlist JSON is not valid.', { body }) | 213 | logger.debug('Remote video playlist JSON is not valid.', { body }) |
diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts index b57bae8fd..6fd53d71b 100644 --- a/server/lib/activitypub/send/utils.ts +++ b/server/lib/activitypub/send/utils.ts | |||
@@ -44,7 +44,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud | |||
44 | async function forwardVideoRelatedActivity ( | 44 | async function forwardVideoRelatedActivity ( |
45 | activity: Activity, | 45 | activity: Activity, |
46 | t: Transaction, | 46 | t: Transaction, |
47 | followersException: MActorWithInboxes[] = [], | 47 | followersException: MActorWithInboxes[], |
48 | video: MVideoId | 48 | video: MVideoId |
49 | ) { | 49 | ) { |
50 | // Mastodon does not add our announces in audience, so we forward to them manually | 50 | // Mastodon does not add our announces in audience, so we forward to them manually |
@@ -161,7 +161,7 @@ async function computeFollowerUris (toFollowersOf: MActorId[], actorsException: | |||
161 | const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) | 161 | const result = await ActorFollowModel.listAcceptedFollowerSharedInboxUrls(toActorFollowerIds, t) |
162 | const sharedInboxesException = await buildSharedInboxesException(actorsException) | 162 | const sharedInboxesException = await buildSharedInboxesException(actorsException) |
163 | 163 | ||
164 | return result.data.filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) | 164 | return result.data.filter(sharedInbox => sharedInboxesException.includes(sharedInbox) === false) |
165 | } | 165 | } |
166 | 166 | ||
167 | async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) { | 167 | async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) { |
@@ -174,7 +174,7 @@ async function computeUris (toActors: MActor[], actorsException: MActorWithInbox | |||
174 | 174 | ||
175 | const sharedInboxesException = await buildSharedInboxesException(actorsException) | 175 | const sharedInboxesException = await buildSharedInboxesException(actorsException) |
176 | return Array.from(toActorSharedInboxesSet) | 176 | return Array.from(toActorSharedInboxesSet) |
177 | .filter(sharedInbox => sharedInboxesException.indexOf(sharedInbox) === -1) | 177 | .filter(sharedInbox => sharedInboxesException.includes(sharedInbox) === false) |
178 | } | 178 | } |
179 | 179 | ||
180 | async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) { | 180 | async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) { |
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index d182ca5a2..bce1666be 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -111,7 +111,7 @@ async function fetchRemoteVideo (videoUrl: string): Promise<{ response: request. | |||
111 | 111 | ||
112 | logger.info('Fetching remote video %s.', videoUrl) | 112 | logger.info('Fetching remote video %s.', videoUrl) |
113 | 113 | ||
114 | const { response, body } = await doRequest(options) | 114 | const { response, body } = await doRequest<any>(options) |
115 | 115 | ||
116 | if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) { | 116 | if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) { |
117 | logger.debug('Remote video JSON is not valid.', { body }) | 117 | logger.debug('Remote video JSON is not valid.', { body }) |
@@ -129,7 +129,7 @@ async function fetchRemoteVideoDescription (video: MVideoAccountLight) { | |||
129 | json: true | 129 | json: true |
130 | } | 130 | } |
131 | 131 | ||
132 | const { body } = await doRequest(options) | 132 | const { body } = await doRequest<any>(options) |
133 | return body.description ? body.description : '' | 133 | return body.description ? body.description : '' |
134 | } | 134 | } |
135 | 135 | ||
@@ -507,7 +507,7 @@ function isAPVideoUrlObject (url: any): url is ActivityVideoUrlObject { | |||
507 | const mimeTypes = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT) | 507 | const mimeTypes = Object.keys(MIMETYPES.VIDEO.MIMETYPE_EXT) |
508 | 508 | ||
509 | const urlMediaType = url.mediaType | 509 | const urlMediaType = url.mediaType |
510 | return mimeTypes.indexOf(urlMediaType) !== -1 && urlMediaType.startsWith('video/') | 510 | return mimeTypes.includes(urlMediaType) && urlMediaType.startsWith('video/') |
511 | } | 511 | } |
512 | 512 | ||
513 | function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject { | 513 | function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject { |
@@ -623,9 +623,11 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc | |||
623 | } | 623 | } |
624 | 624 | ||
625 | function videoActivityObjectToDBAttributes (videoChannel: MChannelId, videoObject: VideoTorrentObject, to: string[] = []) { | 625 | function videoActivityObjectToDBAttributes (videoChannel: MChannelId, videoObject: VideoTorrentObject, to: string[] = []) { |
626 | const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED | 626 | const privacy = to.includes(ACTIVITY_PUB.PUBLIC) |
627 | const duration = videoObject.duration.replace(/[^\d]+/, '') | 627 | ? VideoPrivacy.PUBLIC |
628 | : VideoPrivacy.UNLISTED | ||
628 | 629 | ||
630 | const duration = videoObject.duration.replace(/[^\d]+/, '') | ||
629 | const language = videoObject.language?.identifier | 631 | const language = videoObject.language?.identifier |
630 | 632 | ||
631 | const category = videoObject.category | 633 | const category = videoObject.category |
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index ad4cdd3ab..3de45dd19 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts | |||
@@ -5,7 +5,7 @@ import { updateActorAvatarInstance } from './activitypub' | |||
5 | import { processImage } from '../helpers/image-utils' | 5 | import { processImage } from '../helpers/image-utils' |
6 | import { extname, join } from 'path' | 6 | import { extname, join } from 'path' |
7 | import { retryTransactionWrapper } from '../helpers/database-utils' | 7 | import { retryTransactionWrapper } from '../helpers/database-utils' |
8 | import * as uuidv4 from 'uuid/v4' | 8 | import { v4 as uuidv4 } from 'uuid' |
9 | import { CONFIG } from '../initializers/config' | 9 | import { CONFIG } from '../initializers/config' |
10 | import { sequelizeTypescript } from '../initializers/database' | 10 | import { sequelizeTypescript } from '../initializers/database' |
11 | import * as LRUCache from 'lru-cache' | 11 | import * as LRUCache from 'lru-cache' |
diff --git a/server/lib/user.ts b/server/lib/user.ts index 88e60a7df..316c57359 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as uuidv4 from 'uuid/v4' | 1 | import { v4 as uuidv4 } from 'uuid' |
2 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 2 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
3 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' | 3 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' |
4 | import { AccountModel } from '../models/account/account' | 4 | import { AccountModel } from '../models/account/account' |
diff --git a/server/lib/video-channel.ts b/server/lib/video-channel.ts index 14829c9d6..c9887c667 100644 --- a/server/lib/video-channel.ts +++ b/server/lib/video-channel.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as uuidv4 from 'uuid/v4' | 2 | import { v4 as uuidv4 } from 'uuid' |
3 | import { VideoChannelCreate } from '../../shared/models' | 3 | import { VideoChannelCreate } from '../../shared/models' |
4 | import { VideoChannelModel } from '../models/video/video-channel' | 4 | import { VideoChannelModel } from '../models/video/video-channel' |
5 | import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub' | 5 | import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub' |
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index ab7d04d25..45899818e 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -38,7 +38,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) | |||
38 | 38 | ||
39 | function executeIfActivityPub (req: Request, res: Response, next: NextFunction) { | 39 | function executeIfActivityPub (req: Request, res: Response, next: NextFunction) { |
40 | const accepted = req.accepts(ACCEPT_HEADERS) | 40 | const accepted = req.accepts(ACCEPT_HEADERS) |
41 | if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) { | 41 | if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.includes(accepted) === false) { |
42 | // Bypass this route | 42 | // Bypass this route |
43 | return next('route') | 43 | return next('route') |
44 | } | 44 | } |
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 2a632e16f..625e344fa 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -63,7 +63,7 @@ import { addUserSubscription, removeUserSubscription } from '../../../../shared/ | |||
63 | import { VideoPrivacy } from '../../../../shared/models/videos' | 63 | import { VideoPrivacy } from '../../../../shared/models/videos' |
64 | import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 64 | import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
65 | import { addVideoCommentReply, addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' | 65 | import { addVideoCommentReply, addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' |
66 | import * as uuidv4 from 'uuid/v4' | 66 | import { v4 as uuidv4 } from 'uuid' |
67 | import { addAccountToAccountBlocklist, removeAccountFromAccountBlocklist } from '../../../../shared/extra-utils/users/blocklist' | 67 | import { addAccountToAccountBlocklist, removeAccountFromAccountBlocklist } from '../../../../shared/extra-utils/users/blocklist' |
68 | import { CustomConfig } from '../../../../shared/models/server' | 68 | import { CustomConfig } from '../../../../shared/models/server' |
69 | import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' | 69 | import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' |
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts index 9d3a274d4..611d5254a 100644 --- a/server/tests/api/server/tracker.ts +++ b/server/tests/api/server/tracker.ts | |||
@@ -49,7 +49,7 @@ describe('Test tracker', function () { | |||
49 | torrent.on('error', done) | 49 | torrent.on('error', done) |
50 | torrent.on('warning', warn => { | 50 | torrent.on('warning', warn => { |
51 | const message = typeof warn === 'string' ? warn : warn.message | 51 | const message = typeof warn === 'string' ? warn : warn.message |
52 | if (message.indexOf('Unknown infoHash ') !== -1) return done() | 52 | if (message.includes('Unknown infoHash ')) return done() |
53 | }) | 53 | }) |
54 | 54 | ||
55 | torrent.on('done', () => done(new Error('No error on infohash'))) | 55 | torrent.on('done', () => done(new Error('No error on infohash'))) |
@@ -64,7 +64,7 @@ describe('Test tracker', function () { | |||
64 | torrent.on('error', done) | 64 | torrent.on('error', done) |
65 | torrent.on('warning', warn => { | 65 | torrent.on('warning', warn => { |
66 | const message = typeof warn === 'string' ? warn : warn.message | 66 | const message = typeof warn === 'string' ? warn : warn.message |
67 | if (message.indexOf('Unknown infoHash ') !== -1) return done(new Error('Error on infohash')) | 67 | if (message.includes('Unknown infoHash ')) return done(new Error('Error on infohash')) |
68 | }) | 68 | }) |
69 | 69 | ||
70 | torrent.on('done', done) | 70 | torrent.on('done', done) |
@@ -83,7 +83,7 @@ describe('Test tracker', function () { | |||
83 | torrent.on('error', done) | 83 | torrent.on('error', done) |
84 | torrent.on('warning', warn => { | 84 | torrent.on('warning', warn => { |
85 | const message = typeof warn === 'string' ? warn : warn.message | 85 | const message = typeof warn === 'string' ? warn : warn.message |
86 | if (message.indexOf('disabled ') !== -1) return done() | 86 | if (message.includes('disabled ')) return done() |
87 | }) | 87 | }) |
88 | 88 | ||
89 | torrent.on('done', () => done(new Error('Tracker is enabled'))) | 89 | torrent.on('done', () => done(new Error('Tracker is enabled'))) |
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 304c8ca56..6cda80070 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts | |||
@@ -22,7 +22,7 @@ import { | |||
22 | } from '../../../shared/extra-utils' | 22 | } from '../../../shared/extra-utils' |
23 | import { Account, VideoPlaylistPrivacy } from '../../../shared/models' | 23 | import { Account, VideoPlaylistPrivacy } from '../../../shared/models' |
24 | import { createFile, readdir } from 'fs-extra' | 24 | import { createFile, readdir } from 'fs-extra' |
25 | import * as uuidv4 from 'uuid/v4' | 25 | import { v4 as uuidv4 } from 'uuid' |
26 | import { join } from 'path' | 26 | import { join } from 'path' |
27 | 27 | ||
28 | const expect = chai.expect | 28 | const expect = chai.expect |
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts index 6b486e575..c1a804f83 100644 --- a/server/tools/peertube-auth.ts +++ b/server/tools/peertube-auth.ts | |||
@@ -133,7 +133,7 @@ program | |||
133 | .description('set an existing entry as default') | 133 | .description('set an existing entry as default') |
134 | .action(async url => { | 134 | .action(async url => { |
135 | const settings = await getSettings() | 135 | const settings = await getSettings() |
136 | const instanceExists = settings.remotes.indexOf(url) !== -1 | 136 | const instanceExists = settings.remotes.includes(url) |
137 | 137 | ||
138 | if (instanceExists) { | 138 | if (instanceExists) { |
139 | settings.default = settings.remotes.indexOf(url) | 139 | settings.default = settings.remotes.indexOf(url) |
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 3fb9979df..7f3b58bba 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts | |||
@@ -274,7 +274,7 @@ async function getCategory (categories: string[], url: string) { | |||
274 | function getLicence (licence: string) { | 274 | function getLicence (licence: string) { |
275 | if (!licence) return undefined | 275 | if (!licence) return undefined |
276 | 276 | ||
277 | if (licence.indexOf('Creative Commons Attribution licence') !== -1) return 1 | 277 | if (licence.includes('Creative Commons Attribution licence')) return 1 |
278 | 278 | ||
279 | return undefined | 279 | return undefined |
280 | } | 280 | } |
diff --git a/server/tools/peertube-repl.ts b/server/tools/peertube-repl.ts index 7c936ae0d..ecbba8b0b 100644 --- a/server/tools/peertube-repl.ts +++ b/server/tools/peertube-repl.ts | |||
@@ -2,10 +2,7 @@ import { registerTSPaths } from '../helpers/register-ts-paths' | |||
2 | import * as repl from 'repl' | 2 | import * as repl from 'repl' |
3 | import * as path from 'path' | 3 | import * as path from 'path' |
4 | import * as _ from 'lodash' | 4 | import * as _ from 'lodash' |
5 | import * as uuidv1 from 'uuid/v1' | 5 | import { uuidv1, uuidv3, uuidv4, uuidv5 } from 'uuid' |
6 | import * as uuidv3 from 'uuid/v3' | ||
7 | import * as uuidv4 from 'uuid/v4' | ||
8 | import * as uuidv5 from 'uuid/v5' | ||
9 | import * as Sequelize from 'sequelize' | 6 | import * as Sequelize from 'sequelize' |
10 | import * as YoutubeDL from 'youtube-dl' | 7 | import * as YoutubeDL from 'youtube-dl' |
11 | 8 | ||