aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-20 09:43:39 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit54141398354e6e7b94aa3065a705a1251390111c (patch)
tree8d30d1b9ea8acbe04f6d404125b04fc0c9897b70 /server/controllers/api/videos
parenteb8b27c93e61a896a08923dc1ca3c87ba8cf4948 (diff)
downloadPeerTube-54141398354e6e7b94aa3065a705a1251390111c.tar.gz
PeerTube-54141398354e6e7b94aa3065a705a1251390111c.tar.zst
PeerTube-54141398354e6e7b94aa3065a705a1251390111c.zip
Refractor activity pub lib/helpers
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/channel.ts6
-rw-r--r--server/controllers/api/videos/index.ts11
2 files changed, 9 insertions, 8 deletions
diff --git a/server/controllers/api/videos/channel.ts b/server/controllers/api/videos/channel.ts
index 8f3df2550..ce2656e71 100644
--- a/server/controllers/api/videos/channel.ts
+++ b/server/controllers/api/videos/channel.ts
@@ -17,7 +17,7 @@ import {
17 videoChannelsUpdateValidator 17 videoChannelsUpdateValidator
18} from '../../../middlewares' 18} from '../../../middlewares'
19import { AccountInstance, VideoChannelInstance } from '../../../models' 19import { AccountInstance, VideoChannelInstance } from '../../../models'
20import { sendUpdateVideoChannel } from '../../../lib/activitypub/send-request' 20import { sendUpdateVideoChannel } from '../../../lib/activitypub/send/send-update'
21 21
22const videoChannelRouter = express.Router() 22const videoChannelRouter = express.Router()
23 23
@@ -128,9 +128,9 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
128 if (videoChannelInfoToUpdate.name !== undefined) videoChannelInstance.set('name', videoChannelInfoToUpdate.name) 128 if (videoChannelInfoToUpdate.name !== undefined) videoChannelInstance.set('name', videoChannelInfoToUpdate.name)
129 if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.set('description', videoChannelInfoToUpdate.description) 129 if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.set('description', videoChannelInfoToUpdate.description)
130 130
131 await videoChannelInstance.save(sequelizeOptions) 131 const videoChannelInstanceUpdated = await videoChannelInstance.save(sequelizeOptions)
132 132
133 await sendUpdateVideoChannel(videoChannelInstance, t) 133 await sendUpdateVideoChannel(videoChannelInstanceUpdated, t)
134 }) 134 })
135 135
136 logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.uuid) 136 logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.uuid)
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 22a88620a..8c9b0aa50 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -12,10 +12,11 @@ import {
12 resetSequelizeInstance, 12 resetSequelizeInstance,
13 retryTransactionWrapper 13 retryTransactionWrapper
14} from '../../../helpers' 14} from '../../../helpers'
15import { getActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub' 15import { getVideoActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub'
16import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers' 16import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers'
17import { database as db } from '../../../initializers/database' 17import { database as db } from '../../../initializers/database'
18import { sendAddVideo, sendUpdateVideo } from '../../../lib/activitypub/send-request' 18import { sendAddVideo } from '../../../lib/activitypub/send/send-add'
19import { sendUpdateVideo } from '../../../lib/activitypub/send/send-update'
19import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler' 20import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler'
20import { 21import {
21 asyncMiddleware, 22 asyncMiddleware,
@@ -175,7 +176,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
175 channelId: res.locals.videoChannel.id 176 channelId: res.locals.videoChannel.id
176 } 177 }
177 const video = db.Video.build(videoData) 178 const video = db.Video.build(videoData)
178 video.url = getActivityPubUrl('video', video.uuid) 179 video.url = getVideoActivityPubUrl(video)
179 180
180 const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename) 181 const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename)
181 const videoFileHeight = await getVideoFileHeight(videoFilePath) 182 const videoFileHeight = await getVideoFileHeight(videoFilePath)
@@ -274,7 +275,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
274 if (videoInfoToUpdate.privacy !== undefined) videoInstance.set('privacy', videoInfoToUpdate.privacy) 275 if (videoInfoToUpdate.privacy !== undefined) videoInstance.set('privacy', videoInfoToUpdate.privacy)
275 if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) 276 if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)
276 277
277 await videoInstance.save(sequelizeOptions) 278 const videoInstanceUpdated = await videoInstance.save(sequelizeOptions)
278 279
279 if (videoInfoToUpdate.tags) { 280 if (videoInfoToUpdate.tags) {
280 const tagInstances = await db.Tag.findOrCreateTags(videoInfoToUpdate.tags, t) 281 const tagInstances = await db.Tag.findOrCreateTags(videoInfoToUpdate.tags, t)
@@ -285,7 +286,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
285 286
286 // Now we'll update the video's meta data to our friends 287 // Now we'll update the video's meta data to our friends
287 if (wasPrivateVideo === false) { 288 if (wasPrivateVideo === false) {
288 await sendUpdateVideo(videoInstance, t) 289 await sendUpdateVideo(videoInstanceUpdated, t)
289 } 290 }
290 291
291 // Video is not private anymore, send a create action to remote servers 292 // Video is not private anymore, send a create action to remote servers