aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-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
-rw-r--r--server/lib/user.ts3
-rw-r--r--server/lib/video-comment.ts2
9 files changed, 27 insertions, 20 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 => {
diff --git a/server/lib/user.ts b/server/lib/user.ts
index ce0d60518..7badb3e72 100644
--- a/server/lib/user.ts
+++ b/server/lib/user.ts
@@ -7,7 +7,6 @@ import { UserModel } from '../models/account/user'
7import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub' 7import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'
8import { createVideoChannel } from './video-channel' 8import { createVideoChannel } from './video-channel'
9import { VideoChannelModel } from '../models/video/video-channel' 9import { VideoChannelModel } from '../models/video/video-channel'
10import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
11import { ActorModel } from '../models/activitypub/actor' 10import { ActorModel } from '../models/activitypub/actor'
12import { UserNotificationSettingModel } from '../models/account/user-notification-setting' 11import { UserNotificationSettingModel } from '../models/account/user-notification-setting'
13import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users' 12import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'
@@ -73,7 +72,7 @@ async function createLocalAccountWithoutKeys (
73 userId, 72 userId,
74 applicationId, 73 applicationId,
75 actorId: actorInstanceCreated.id 74 actorId: actorInstanceCreated.id
76 } as FilteredModelAttributes<AccountModel>) 75 })
77 76
78 const accountInstanceCreated = await accountInstance.save({ transaction: t }) 77 const accountInstanceCreated = await accountInstance.save({ transaction: t })
79 accountInstanceCreated.Actor = actorInstanceCreated 78 accountInstanceCreated.Actor = actorInstanceCreated
diff --git a/server/lib/video-comment.ts b/server/lib/video-comment.ts
index 59bce7520..bfe22d225 100644
--- a/server/lib/video-comment.ts
+++ b/server/lib/video-comment.ts
@@ -28,7 +28,7 @@ async function createVideoComment (obj: {
28 videoId: obj.video.id, 28 videoId: obj.video.id,
29 accountId: obj.account.id, 29 accountId: obj.account.id,
30 url: 'fake url' 30 url: 'fake url'
31 }, { transaction: t, validate: false }) 31 }, { transaction: t, validate: false } as any) // FIXME: sequelize typings
32 32
33 comment.set('url', getVideoCommentActivityPubUrl(obj.video, comment)) 33 comment.set('url', getVideoCommentActivityPubUrl(obj.video, comment))
34 34