aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/actor.ts6
-rw-r--r--server/lib/activitypub/playlist.ts6
-rw-r--r--server/lib/activitypub/send/utils.ts6
-rw-r--r--server/lib/activitypub/videos.ts12
-rw-r--r--server/lib/avatar.ts2
-rw-r--r--server/lib/user.ts2
-rw-r--r--server/lib/video-channel.ts2
7 files changed, 20 insertions, 16 deletions
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 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { Transaction } from 'sequelize' 2import { Transaction } from 'sequelize'
3import { URL } from 'url' 3import { URL } from 'url'
4import * as uuidv4 from 'uuid/v4' 4import { v4 as uuidv4 } from 'uuid'
5import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub' 5import { ActivityPubActor, ActivityPubActorType, ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
6import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' 6import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects'
7import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' 7import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
8import { sanitizeAndCheckActorObject } from '../../helpers/custom-validators/activitypub/actor' 8import { 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'
20import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist' 20import { MVideoPlaylist, MVideoPlaylistId, MVideoPlaylistOwner } from '../../typings/models/video/video-playlist'
21 21
22function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: MAccountId, to: string[]) { 22function 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
44async function forwardVideoRelatedActivity ( 44async 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
167async function computeUris (toActors: MActor[], actorsException: MActorWithInboxes[] = []) { 167async 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
180async function buildSharedInboxesException (actorsException: MActorWithInboxes[]) { 180async 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
513function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject { 513function isAPStreamingPlaylistUrlObject (url: ActivityUrlObject): url is ActivityPlaylistUrlObject {
@@ -623,9 +623,11 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc
623} 623}
624 624
625function videoActivityObjectToDBAttributes (videoChannel: MChannelId, videoObject: VideoTorrentObject, to: string[] = []) { 625function 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'
5import { processImage } from '../helpers/image-utils' 5import { processImage } from '../helpers/image-utils'
6import { extname, join } from 'path' 6import { extname, join } from 'path'
7import { retryTransactionWrapper } from '../helpers/database-utils' 7import { retryTransactionWrapper } from '../helpers/database-utils'
8import * as uuidv4 from 'uuid/v4' 8import { v4 as uuidv4 } from 'uuid'
9import { CONFIG } from '../initializers/config' 9import { CONFIG } from '../initializers/config'
10import { sequelizeTypescript } from '../initializers/database' 10import { sequelizeTypescript } from '../initializers/database'
11import * as LRUCache from 'lru-cache' 11import * 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 @@
1import * as uuidv4 from 'uuid/v4' 1import { v4 as uuidv4 } from 'uuid'
2import { ActivityPubActorType } from '../../shared/models/activitypub' 2import { ActivityPubActorType } from '../../shared/models/activitypub'
3import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants' 3import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
4import { AccountModel } from '../models/account/account' 4import { 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 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as uuidv4 from 'uuid/v4' 2import { v4 as uuidv4 } from 'uuid'
3import { VideoChannelCreate } from '../../shared/models' 3import { VideoChannelCreate } from '../../shared/models'
4import { VideoChannelModel } from '../models/video/video-channel' 4import { VideoChannelModel } from '../models/video/video-channel'
5import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub' 5import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub'