aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub/client.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-14 17:38:41 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:53:16 +0100
commit50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch)
treef1732b27edcd05c7877a8358b8312f1e38c287ed /server/controllers/activitypub/client.ts
parentfadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff)
downloadPeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.gz
PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.zst
PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.zip
Begin moving video channel to actor
Diffstat (limited to 'server/controllers/activitypub/client.ts')
-rw-r--r--server/controllers/activitypub/client.ts31
1 files changed, 6 insertions, 25 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 72b216254..8c6294ff7 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -2,20 +2,13 @@
2import * as express from 'express' 2import * as express from 'express'
3import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers' 3import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers'
4import { ACTIVITY_PUB, CONFIG } from '../../initializers' 4import { ACTIVITY_PUB, CONFIG } from '../../initializers'
5import { buildVideoChannelAnnounceToFollowers } from '../../lib/activitypub/send' 5import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send'
6import { buildVideoAnnounceToFollowers } from '../../lib/index'
7import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' 6import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares'
8import { 7import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators'
9 videoChannelsGetValidator,
10 videoChannelsShareValidator,
11 videosGetValidator,
12 videosShareValidator
13} from '../../middlewares/validators'
14import { AccountModel } from '../../models/account/account' 8import { AccountModel } from '../../models/account/account'
15import { AccountFollowModel } from '../../models/account/account-follow' 9import { ActorFollowModel } from '../../models/activitypub/actor-follow'
16import { VideoModel } from '../../models/video/video' 10import { VideoModel } from '../../models/video/video'
17import { VideoChannelModel } from '../../models/video/video-channel' 11import { VideoChannelModel } from '../../models/video/video-channel'
18import { VideoChannelShareModel } from '../../models/video/video-channel-share'
19import { VideoShareModel } from '../../models/video/video-share' 12import { VideoShareModel } from '../../models/video/video-share'
20 13
21const activityPubClientRouter = express.Router() 14const activityPubClientRouter = express.Router()
@@ -50,11 +43,6 @@ activityPubClientRouter.get('/video-channels/:id',
50 executeIfActivityPub(asyncMiddleware(videoChannelController)) 43 executeIfActivityPub(asyncMiddleware(videoChannelController))
51) 44)
52 45
53activityPubClientRouter.get('/video-channels/:id/announces/:accountId',
54 executeIfActivityPub(asyncMiddleware(videoChannelsShareValidator)),
55 executeIfActivityPub(asyncMiddleware(videoChannelAnnounceController))
56)
57
58// --------------------------------------------------------------------------- 46// ---------------------------------------------------------------------------
59 47
60export { 48export {
@@ -75,7 +63,7 @@ async function accountFollowersController (req: express.Request, res: express.Re
75 const page = req.query.page || 1 63 const page = req.query.page || 1
76 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) 64 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
77 65
78 const result = await AccountFollowModel.listAcceptedFollowerUrlsForApi([ account.id ], undefined, start, count) 66 const result = await ActorFollowModel.listAcceptedFollowerUrlsForApi([ account.Actor.id ], undefined, start, count)
79 const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) 67 const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result)
80 68
81 return res.json(activityPubResult) 69 return res.json(activityPubResult)
@@ -87,7 +75,7 @@ async function accountFollowingController (req: express.Request, res: express.Re
87 const page = req.query.page || 1 75 const page = req.query.page || 1
88 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) 76 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
89 77
90 const result = await AccountFollowModel.listAcceptedFollowingUrlsForApi([ account.id ], undefined, start, count) 78 const result = await ActorFollowModel.listAcceptedFollowingUrlsForApi([ account.Actor.id ], undefined, start, count)
91 const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result) 79 const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result)
92 80
93 return res.json(activityPubResult) 81 return res.json(activityPubResult)
@@ -101,14 +89,7 @@ function videoController (req: express.Request, res: express.Response, next: exp
101 89
102async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { 90async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) {
103 const share = res.locals.videoShare as VideoShareModel 91 const share = res.locals.videoShare as VideoShareModel
104 const object = await buildVideoAnnounceToFollowers(share.Account, res.locals.video, undefined) 92 const object = await buildVideoAnnounceToFollowers(share.Actor, res.locals.video, undefined)
105
106 return res.json(object)
107}
108
109async function videoChannelAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) {
110 const share = res.locals.videoChannelShare as VideoChannelShareModel
111 const object = await buildVideoChannelAnnounceToFollowers(share.Account, share.VideoChannel, undefined)
112 93
113 return res.json(object) 94 return res.json(object)
114} 95}