X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideos%2Findex.ts;h=0d114dcd2d37fcb983299faff9824ad96675fdfe;hb=892211e8493b1f992fce7616cb1e48b7ff87a1dc;hp=22a88620a8ac12fa75cb8d14ac8fefa07c8b7306;hpb=572f8d3dba44ba874f5c51023214273e3f5b643c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 22a88620a..0d114dcd2 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -3,7 +3,6 @@ import * as multer from 'multer' import { extname, join } from 'path' import { VideoCreate, VideoPrivacy, VideoUpdate } from '../../../../shared' import { - fetchRemoteVideoDescription, generateRandomString, getFormattedObjects, getVideoFileHeight, @@ -12,10 +11,10 @@ import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers' -import { getActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub' import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers' import { database as db } from '../../../initializers/database' -import { sendAddVideo, sendUpdateVideo } from '../../../lib/activitypub/send-request' +import { sendAddVideo } from '../../../lib/activitypub/send/send-add' +import { sendUpdateVideo } from '../../../lib/activitypub/send/send-update' import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler' import { asyncMiddleware, @@ -36,6 +35,9 @@ import { abuseVideoRouter } from './abuse' import { blacklistRouter } from './blacklist' import { videoChannelRouter } from './channel' import { rateVideoRouter } from './rate' +import { getVideoActivityPubUrl } from '../../../lib/activitypub/url' +import { shareVideoByServer } from '../../../lib/activitypub/share' +import { fetchRemoteVideoDescription } from '../../../lib/activitypub/videos' const videosRouter = express.Router() @@ -175,7 +177,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi channelId: res.locals.videoChannel.id } const video = db.Video.build(videoData) - video.url = getActivityPubUrl('video', video.uuid) + video.url = getVideoActivityPubUrl(video) const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename) const videoFileHeight = await getVideoFileHeight(videoFilePath) @@ -274,7 +276,7 @@ async function updateVideo (req: express.Request, res: express.Response) { if (videoInfoToUpdate.privacy !== undefined) videoInstance.set('privacy', videoInfoToUpdate.privacy) if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) - await videoInstance.save(sequelizeOptions) + const videoInstanceUpdated = await videoInstance.save(sequelizeOptions) if (videoInfoToUpdate.tags) { const tagInstances = await db.Tag.findOrCreateTags(videoInfoToUpdate.tags, t) @@ -285,7 +287,7 @@ async function updateVideo (req: express.Request, res: express.Response) { // Now we'll update the video's meta data to our friends if (wasPrivateVideo === false) { - await sendUpdateVideo(videoInstance, t) + await sendUpdateVideo(videoInstanceUpdated, t) } // Video is not private anymore, send a create action to remote servers