diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-14 17:38:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch) | |
tree | f1732b27edcd05c7877a8358b8312f1e38c287ed /server/controllers/activitypub/client.ts | |
parent | fadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff) | |
download | PeerTube-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.ts | 31 |
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 @@ | |||
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers' | 3 | import { activityPubCollectionPagination, pageToStartAndCount } from '../../helpers' |
4 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' | 4 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' |
5 | import { buildVideoChannelAnnounceToFollowers } from '../../lib/activitypub/send' | 5 | import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' |
6 | import { buildVideoAnnounceToFollowers } from '../../lib/index' | ||
7 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' | 6 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' |
8 | import { | 7 | import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' |
9 | videoChannelsGetValidator, | ||
10 | videoChannelsShareValidator, | ||
11 | videosGetValidator, | ||
12 | videosShareValidator | ||
13 | } from '../../middlewares/validators' | ||
14 | import { AccountModel } from '../../models/account/account' | 8 | import { AccountModel } from '../../models/account/account' |
15 | import { AccountFollowModel } from '../../models/account/account-follow' | 9 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
16 | import { VideoModel } from '../../models/video/video' | 10 | import { VideoModel } from '../../models/video/video' |
17 | import { VideoChannelModel } from '../../models/video/video-channel' | 11 | import { VideoChannelModel } from '../../models/video/video-channel' |
18 | import { VideoChannelShareModel } from '../../models/video/video-channel-share' | ||
19 | import { VideoShareModel } from '../../models/video/video-share' | 12 | import { VideoShareModel } from '../../models/video/video-share' |
20 | 13 | ||
21 | const activityPubClientRouter = express.Router() | 14 | const activityPubClientRouter = express.Router() |
@@ -50,11 +43,6 @@ activityPubClientRouter.get('/video-channels/:id', | |||
50 | executeIfActivityPub(asyncMiddleware(videoChannelController)) | 43 | executeIfActivityPub(asyncMiddleware(videoChannelController)) |
51 | ) | 44 | ) |
52 | 45 | ||
53 | activityPubClientRouter.get('/video-channels/:id/announces/:accountId', | ||
54 | executeIfActivityPub(asyncMiddleware(videoChannelsShareValidator)), | ||
55 | executeIfActivityPub(asyncMiddleware(videoChannelAnnounceController)) | ||
56 | ) | ||
57 | |||
58 | // --------------------------------------------------------------------------- | 46 | // --------------------------------------------------------------------------- |
59 | 47 | ||
60 | export { | 48 | export { |
@@ -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 | ||
102 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { | 90 | async 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 | |||
109 | async 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 | } |