aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-18 11:28:17 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:20 +0200
commit1735c825726edaa0af5035cb6cbb0cc0db502c6d (patch)
tree7bbb442f2cb4d7be58a4e08d87f5974403a3047c /server/lib/activitypub
parente8bafea35bc930cb8ac5b2d521a188642a1adffe (diff)
downloadPeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.gz
PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.zst
PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.zip
Update sequelize
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/cache-file.ts4
-rw-r--r--server/lib/activitypub/playlist.ts6
-rw-r--r--server/lib/activitypub/process/process-follow.ts4
-rw-r--r--server/lib/activitypub/process/process-update.ts8
-rw-r--r--server/lib/activitypub/video-comments.ts3
-rw-r--r--server/lib/activitypub/video-rates.ts5
-rw-r--r--server/lib/activitypub/videos.ts12
7 files changed, 25 insertions, 17 deletions
diff --git a/server/lib/activitypub/cache-file.ts b/server/lib/activitypub/cache-file.ts
index 597003135..de5cc54ac 100644
--- a/server/lib/activitypub/cache-file.ts
+++ b/server/lib/activitypub/cache-file.ts
@@ -68,8 +68,8 @@ function updateCacheFile (
68 68
69 const attributes = cacheFileActivityObjectToDBAttributes(cacheFileObject, video, byActor) 69 const attributes = cacheFileActivityObjectToDBAttributes(cacheFileObject, video, byActor)
70 70
71 redundancyModel.set('expires', attributes.expiresOn) 71 redundancyModel.expiresOn = attributes.expiresOn
72 redundancyModel.set('fileUrl', attributes.fileUrl) 72 redundancyModel.fileUrl = attributes.fileUrl
73 73
74 return redundancyModel.save({ transaction: t }) 74 return redundancyModel.save({ transaction: t })
75} 75}
diff --git a/server/lib/activitypub/playlist.ts b/server/lib/activitypub/playlist.ts
index 341e469f3..721c19603 100644
--- a/server/lib/activitypub/playlist.ts
+++ b/server/lib/activitypub/playlist.ts
@@ -14,7 +14,6 @@ import { getOrCreateVideoAndAccountAndChannel } from './videos'
14import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '../../helpers/custom-validators/activitypub/playlist' 14import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '../../helpers/custom-validators/activitypub/playlist'
15import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' 15import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
16import { VideoModel } from '../../models/video/video' 16import { VideoModel } from '../../models/video/video'
17import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
18import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 17import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
19import { sequelizeTypescript } from '../../initializers/database' 18import { sequelizeTypescript } from '../../initializers/database'
20import { createPlaylistThumbnailFromUrl } from '../thumbnail' 19import { createPlaylistThumbnailFromUrl } from '../thumbnail'
@@ -87,7 +86,8 @@ async function createOrUpdateVideoPlaylist (playlistObject: PlaylistObject, byAc
87 } 86 }
88 } 87 }
89 88
90 const [ playlist ] = await VideoPlaylistModel.upsert<VideoPlaylistModel>(playlistAttributes, { returning: true }) 89 // FIXME: sequelize typings
90 const [ playlist ] = (await VideoPlaylistModel.upsert<VideoPlaylistModel>(playlistAttributes, { returning: true }) as any)
91 91
92 let accItems: string[] = [] 92 let accItems: string[] = []
93 await crawlCollectionPage<string>(playlistObject.id, items => { 93 await crawlCollectionPage<string>(playlistObject.id, items => {
@@ -156,7 +156,7 @@ export {
156// --------------------------------------------------------------------------- 156// ---------------------------------------------------------------------------
157 157
158async function resetVideoPlaylistElements (elementUrls: string[], playlist: VideoPlaylistModel) { 158async function resetVideoPlaylistElements (elementUrls: string[], playlist: VideoPlaylistModel) {
159 const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = [] 159 const elementsToCreate: object[] = [] // FIXME: sequelize typings
160 160
161 await Bluebird.map(elementUrls, async elementUrl => { 161 await Bluebird.map(elementUrls, async elementUrl => {
162 try { 162 try {
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index ac3dd6ac4..ed16ba172 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -37,7 +37,9 @@ async function processFollow (actor: ActorModel, targetActorURL: string) {
37 if (isFollowingInstance && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { 37 if (isFollowingInstance && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) {
38 logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) 38 logger.info('Rejecting %s because instance followers are disabled.', targetActor.url)
39 39
40 return sendReject(actor, targetActor) 40 await sendReject(actor, targetActor)
41
42 return { actorFollow: undefined }
41 } 43 }
42 44
43 const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({ 45 const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 0b96ba352..54a9234bb 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -120,9 +120,11 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
120 120
121 await actor.save({ transaction: t }) 121 await actor.save({ transaction: t })
122 122
123 accountOrChannelInstance.set('name', actorAttributesToUpdate.name || actorAttributesToUpdate.preferredUsername) 123 accountOrChannelInstance.name = actorAttributesToUpdate.name || actorAttributesToUpdate.preferredUsername
124 accountOrChannelInstance.set('description', actorAttributesToUpdate.summary) 124 accountOrChannelInstance.description = actorAttributesToUpdate.summary
125 accountOrChannelInstance.set('support', actorAttributesToUpdate.support) 125
126 if (accountOrChannelInstance instanceof VideoChannelModel) accountOrChannelInstance.support = actorAttributesToUpdate.support
127
126 await accountOrChannelInstance.save({ transaction: t }) 128 await accountOrChannelInstance.save({ transaction: t })
127 }) 129 })
128 130
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 18f44d50e..cb67bf9a4 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -73,7 +73,8 @@ async function addVideoComment (videoInstance: VideoModel, commentUrl: string) {
73 const entry = await videoCommentActivityObjectToDBAttributes(videoInstance, actor, body) 73 const entry = await videoCommentActivityObjectToDBAttributes(videoInstance, actor, body)
74 if (!entry) return { created: false } 74 if (!entry) return { created: false }
75 75
76 const [ comment, created ] = await VideoCommentModel.upsert<VideoCommentModel>(entry, { returning: true }) 76 // FIXME: sequelize typings
77 const [ comment, created ] = (await VideoCommentModel.upsert<VideoCommentModel>(entry, { returning: true }) as any)
77 comment.Account = actor.Account 78 comment.Account = actor.Account
78 comment.Video = videoInstance 79 comment.Video = videoInstance
79 80
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts
index 7809c58b8..cda5b2981 100644
--- a/server/lib/activitypub/video-rates.ts
+++ b/server/lib/activitypub/video-rates.ts
@@ -56,7 +56,10 @@ async function createRates (ratesUrl: string[], video: VideoModel, rate: VideoRa
56 logger.info('Adding %d %s to video %s.', rateCounts, rate, video.uuid) 56 logger.info('Adding %d %s to video %s.', rateCounts, rate, video.uuid)
57 57
58 // This is "likes" and "dislikes" 58 // This is "likes" and "dislikes"
59 if (rateCounts !== 0) await video.increment(rate + 's', { by: rateCounts }) 59 if (rateCounts !== 0) {
60 const field = rate === 'like' ? 'likes' : 'dislikes'
61 await video.increment(field, { by: rateCounts })
62 }
60 63
61 return 64 return
62} 65}
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 16c37a55f..5a56942a9 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -6,7 +6,7 @@ import {
6 ActivityPlaylistSegmentHashesObject, 6 ActivityPlaylistSegmentHashesObject,
7 ActivityPlaylistUrlObject, 7 ActivityPlaylistUrlObject,
8 ActivityUrlObject, 8 ActivityUrlObject,
9 ActivityVideoUrlObject, VideoCreate, 9 ActivityVideoUrlObject,
10 VideoState 10 VideoState
11} from '../../../shared/index' 11} from '../../../shared/index'
12import { VideoTorrentObject } from '../../../shared/models/activitypub/objects' 12import { VideoTorrentObject } from '../../../shared/models/activitypub/objects'
@@ -45,7 +45,6 @@ import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
45import { Notifier } from '../notifier' 45import { Notifier } from '../notifier'
46import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' 46import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
47import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' 47import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
48import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
49import { AccountVideoRateModel } from '../../models/account/account-video-rate' 48import { AccountVideoRateModel } from '../../models/account/account-video-rate'
50import { VideoShareModel } from '../../models/video/video-share' 49import { VideoShareModel } from '../../models/video/video-share'
51import { VideoCommentModel } from '../../models/video/video-comment' 50import { VideoCommentModel } from '../../models/video/video-comment'
@@ -312,7 +311,7 @@ async function updateVideoFromAP (options: {
312 311
313 // Update or add other one 312 // Update or add other one
314 const upsertTasks = videoFileAttributes.map(a => { 313 const upsertTasks = videoFileAttributes.map(a => {
315 return VideoFileModel.upsert<VideoFileModel>(a, { returning: true, transaction: t }) 314 return (VideoFileModel.upsert<VideoFileModel>(a, { returning: true, transaction: t }) as any) // FIXME: sequelize typings
316 .then(([ file ]) => file) 315 .then(([ file ]) => file)
317 }) 316 })
318 317
@@ -335,7 +334,8 @@ async function updateVideoFromAP (options: {
335 334
336 // Update or add other one 335 // Update or add other one
337 const upsertTasks = streamingPlaylistAttributes.map(a => { 336 const upsertTasks = streamingPlaylistAttributes.map(a => {
338 return VideoStreamingPlaylistModel.upsert<VideoStreamingPlaylistModel>(a, { returning: true, transaction: t }) 337 // FIXME: sequelize typings
338 return (VideoStreamingPlaylistModel.upsert<VideoStreamingPlaylistModel>(a, { returning: true, transaction: t }) as any)
339 .then(([ streamingPlaylist ]) => streamingPlaylist) 339 .then(([ streamingPlaylist ]) => streamingPlaylist)
340 }) 340 })
341 341
@@ -594,7 +594,7 @@ function videoFileActivityUrlToDBAttributes (video: VideoModel, videoObject: Vid
594 throw new Error('Cannot find video files for ' + video.url) 594 throw new Error('Cannot find video files for ' + video.url)
595 } 595 }
596 596
597 const attributes: FilteredModelAttributes<VideoFileModel>[] = [] 597 const attributes: object[] = [] // FIXME: add typings
598 for (const fileUrl of fileUrls) { 598 for (const fileUrl of fileUrls) {
599 // Fetch associated magnet uri 599 // Fetch associated magnet uri
600 const magnet = videoObject.url.find(u => { 600 const magnet = videoObject.url.find(u => {
@@ -629,7 +629,7 @@ function streamingPlaylistActivityUrlToDBAttributes (video: VideoModel, videoObj
629 const playlistUrls = videoObject.url.filter(u => isAPStreamingPlaylistUrlObject(u)) as ActivityPlaylistUrlObject[] 629 const playlistUrls = videoObject.url.filter(u => isAPStreamingPlaylistUrlObject(u)) as ActivityPlaylistUrlObject[]
630 if (playlistUrls.length === 0) return [] 630 if (playlistUrls.length === 0) return []
631 631
632 const attributes: FilteredModelAttributes<VideoStreamingPlaylistModel>[] = [] 632 const attributes: object[] = [] // FIXME: add typings
633 for (const playlistUrlObject of playlistUrls) { 633 for (const playlistUrlObject of playlistUrls) {
634 const segmentsSha256UrlObject = playlistUrlObject.tag 634 const segmentsSha256UrlObject = playlistUrlObject.tag
635 .find(t => { 635 .find(t => {