diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-28 16:03:39 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-28 16:21:34 +0100 |
commit | bdd428a6d9138d751f8cde82867022a93f1a76cc (patch) | |
tree | c2b671c3d6a34daddd20e30656f573cf59905f13 /server/lib | |
parent | 9d94e5d7b96332d628ed835c67c2986289ead9b2 (diff) | |
download | PeerTube-bdd428a6d9138d751f8cde82867022a93f1a76cc.tar.gz PeerTube-bdd428a6d9138d751f8cde82867022a93f1a76cc.tar.zst PeerTube-bdd428a6d9138d751f8cde82867022a93f1a76cc.zip |
Update dependencies
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/actor.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/playlist.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/send/utils.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 12 | ||||
-rw-r--r-- | server/lib/avatar.ts | 2 | ||||
-rw-r--r-- | server/lib/user.ts | 2 | ||||
-rw-r--r-- | server/lib/video-channel.ts | 2 |
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 @@ | |||
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' |