import { database as db } from '../../initializers'
import { executeIfActivityPub, localAccountValidator } from '../../middlewares'
import { pageToStartAndCount } from '../../helpers'
-import { AccountInstance } from '../../models'
+import { AccountInstance, VideoChannelInstance } from '../../models'
import { activityPubCollectionPagination } from '../../helpers/activitypub'
-import { ACTIVITY_PUB } from '../../initializers/constants'
+import { ACTIVITY_PUB, CONFIG } from '../../initializers/constants'
import { asyncMiddleware } from '../../middlewares/async'
+import { videosGetValidator } from '../../middlewares/validators/videos'
+import { VideoInstance } from '../../models/video/video-interface'
+import { videoChannelsGetValidator } from '../../middlewares/validators/video-channels'
const activityPubClientRouter = express.Router()
executeIfActivityPub(asyncMiddleware(accountFollowingController))
)
+activityPubClientRouter.get('/videos/watch/:id',
+ executeIfActivityPub(videosGetValidator),
+ executeIfActivityPub(asyncMiddleware(videoController))
+)
+
+activityPubClientRouter.get('/video-channels/:id',
+ executeIfActivityPub(videoChannelsGetValidator),
+ executeIfActivityPub(asyncMiddleware(videoChannelController))
+)
+
// ---------------------------------------------------------------------------
export {
const page = req.params.page || 1
const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
- const result = await db.Account.listAcceptedFollowerUrlsForApi(account.id, start, count)
- const activityPubResult = activityPubCollectionPagination(req.url, page, result)
+ const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi([ account.id ], start, count)
+ const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result)
return res.json(activityPubResult)
}
const page = req.params.page || 1
const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
- const result = await db.Account.listAcceptedFollowingUrlsForApi(account.id, start, count)
- const activityPubResult = activityPubCollectionPagination(req.url, page, result)
+ const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi([ account.id ], start, count)
+ const activityPubResult = activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, page, result)
return res.json(activityPubResult)
}
+
+async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const video: VideoInstance = res.locals.video
+
+ return res.json(video.toActivityPubObject())
+}
+
+async function videoChannelController (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const videoChannel: VideoChannelInstance = res.locals.videoChannel
+
+ return res.json(videoChannel.toActivityPubObject())
+}