diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 11:08:25 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | efc32059d980c51793e8e9ac0fb6a885a8026f94 (patch) | |
tree | c272e63fd57a9625b53dc26ceb1b46aee35d21d3 /server/controllers/api | |
parent | d846501818c2d29e66e6fd141789cb04fd55a437 (diff) | |
download | PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.tar.gz PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.tar.zst PeerTube-efc32059d980c51793e8e9ac0fb6a885a8026f94.zip |
Send server announce when users upload a video
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/server/follows.ts | 8 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 11 |
2 files changed, 10 insertions, 9 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index ac8ea87f9..e00787f02 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { UserRight } from '../../../../shared/models/users/user-right.enum' | 2 | import { UserRight } from '../../../../shared/models/users/user-right.enum' |
3 | import { getFormattedObjects } from '../../../helpers' | 3 | import { getFormattedObjects } from '../../../helpers' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { getApplicationAccount } from '../../../helpers/utils' | 5 | import { getServerAccount } from '../../../helpers/utils' |
6 | import { getAccountFromWebfinger } from '../../../helpers/webfinger' | 6 | import { getAccountFromWebfinger } from '../../../helpers/webfinger' |
7 | import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants' | 7 | import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants' |
8 | import { database as db } from '../../../initializers/database' | 8 | import { database as db } from '../../../initializers/database' |
@@ -50,14 +50,14 @@ export { | |||
50 | // --------------------------------------------------------------------------- | 50 | // --------------------------------------------------------------------------- |
51 | 51 | ||
52 | async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) { | 52 | async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) { |
53 | const applicationAccount = await getApplicationAccount() | 53 | const applicationAccount = await getServerAccount() |
54 | const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) | 54 | const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) |
55 | 55 | ||
56 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 56 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
57 | } | 57 | } |
58 | 58 | ||
59 | async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) { | 59 | async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) { |
60 | const applicationAccount = await getApplicationAccount() | 60 | const applicationAccount = await getServerAccount() |
61 | const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) | 61 | const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) |
62 | 62 | ||
63 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 63 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
@@ -65,7 +65,7 @@ async function listFollowers (req: express.Request, res: express.Response, next: | |||
65 | 65 | ||
66 | async function follow (req: express.Request, res: express.Response, next: express.NextFunction) { | 66 | async function follow (req: express.Request, res: express.Response, next: express.NextFunction) { |
67 | const hosts = req.body.hosts as string[] | 67 | const hosts = req.body.hosts as string[] |
68 | const fromAccount = await getApplicationAccount() | 68 | const fromAccount = await getServerAccount() |
69 | 69 | ||
70 | const tasks: Promise<any>[] = [] | 70 | const tasks: Promise<any>[] = [] |
71 | const accountName = SERVER_ACCOUNT_NAME | 71 | const accountName = SERVER_ACCOUNT_NAME |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index ebc07e179..a5414cc50 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -12,10 +12,10 @@ import { | |||
12 | resetSequelizeInstance, | 12 | resetSequelizeInstance, |
13 | retryTransactionWrapper | 13 | retryTransactionWrapper |
14 | } from '../../../helpers' | 14 | } from '../../../helpers' |
15 | import { getActivityPubUrl } from '../../../helpers/activitypub' | 15 | import { getActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub' |
16 | import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers' | 16 | import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers' |
17 | import { database as db } from '../../../initializers/database' | 17 | import { database as db } from '../../../initializers/database' |
18 | import { sendAddVideo, sendUpdateVideoChannel } from '../../../lib/activitypub/send-request' | 18 | import { sendAddVideo, sendUpdateVideo } from '../../../lib/activitypub/send-request' |
19 | import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler' | 19 | import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler' |
20 | import { | 20 | import { |
21 | asyncMiddleware, | 21 | asyncMiddleware, |
@@ -56,7 +56,7 @@ const storage = multer.diskStorage({ | |||
56 | randomString = 'fake-random-string' | 56 | randomString = 'fake-random-string' |
57 | } | 57 | } |
58 | 58 | ||
59 | cb(null, randomString + '.' + extension) | 59 | cb(null, randomString + extension) |
60 | } | 60 | } |
61 | }) | 61 | }) |
62 | 62 | ||
@@ -237,6 +237,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi | |||
237 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined | 237 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined |
238 | 238 | ||
239 | await sendAddVideo(video, t) | 239 | await sendAddVideo(video, t) |
240 | await shareVideoByServer(video, t) | ||
240 | }) | 241 | }) |
241 | 242 | ||
242 | logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoUUID) | 243 | logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoUUID) |
@@ -254,7 +255,7 @@ async function updateVideoRetryWrapper (req: express.Request, res: express.Respo | |||
254 | } | 255 | } |
255 | 256 | ||
256 | async function updateVideo (req: express.Request, res: express.Response) { | 257 | async function updateVideo (req: express.Request, res: express.Response) { |
257 | const videoInstance = res.locals.video | 258 | const videoInstance: VideoInstance = res.locals.video |
258 | const videoFieldsSave = videoInstance.toJSON() | 259 | const videoFieldsSave = videoInstance.toJSON() |
259 | const videoInfoToUpdate: VideoUpdate = req.body | 260 | const videoInfoToUpdate: VideoUpdate = req.body |
260 | const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE | 261 | const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE |
@@ -284,7 +285,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
284 | 285 | ||
285 | // Now we'll update the video's meta data to our friends | 286 | // Now we'll update the video's meta data to our friends |
286 | if (wasPrivateVideo === false) { | 287 | if (wasPrivateVideo === false) { |
287 | await sendUpdateVideoChannel(videoInstance, t) | 288 | await sendUpdateVideo(videoInstance, t) |
288 | } | 289 | } |
289 | 290 | ||
290 | // Video is not private anymore, send a create action to remote servers | 291 | // Video is not private anymore, send a create action to remote servers |