diff options
Diffstat (limited to 'server/lib/activitypub')
-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 |
4 files changed, 17 insertions, 13 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 |