PeerTube/server/controllers/activitypub/client.ts

438 lines
17 KiB
TypeScript
Raw Normal View History

2020-04-10 15:52:01 +02:00
import * as cors from 'cors'
2020-11-06 10:57:40 +01:00
import * as express from 'express'
import { getServerActor } from '@server/models/application/application'
2020-11-20 11:34:49 +01:00
import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
2020-11-06 10:57:40 +01:00
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
2018-01-26 11:44:08 +01:00
import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants'
2018-05-25 11:32:36 +02:00
import { audiencify, getAudience } from '../../lib/activitypub/audience'
2020-11-06 10:57:40 +01:00
import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send'
2018-09-11 16:27:07 +02:00
import { buildCreateActivity } from '../../lib/activitypub/send/send-create'
2020-11-06 10:57:40 +01:00
import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike'
import {
2020-11-20 11:21:08 +01:00
getLocalVideoCommentsActivityPubUrl,
getLocalVideoDislikesActivityPubUrl,
getLocalVideoLikesActivityPubUrl,
getLocalVideoSharesActivityPubUrl
2020-11-06 10:57:40 +01:00
} from '../../lib/activitypub/url'
import {
asyncMiddleware,
executeIfActivityPub,
localAccountValidator,
localVideoChannelValidator,
videosCustomGetValidator,
videosShareValidator
} from '../../middlewares'
2020-11-06 10:57:40 +01:00
import { cacheRoute } from '../../middlewares/cache'
import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators'
2020-11-06 10:57:40 +01:00
import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
2017-12-12 17:53:50 +01:00
import { AccountModel } from '../../models/account/account'
2020-11-06 10:57:40 +01:00
import { AccountVideoRateModel } from '../../models/account/account-video-rate'
2017-12-14 17:38:41 +01:00
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
2017-12-12 17:53:50 +01:00
import { VideoModel } from '../../models/video/video'
2020-11-06 10:57:40 +01:00
import { VideoCaptionModel } from '../../models/video/video-caption'
2017-12-28 11:16:08 +01:00
import { VideoCommentModel } from '../../models/video/video-comment'
2020-11-06 10:57:40 +01:00
import { VideoPlaylistModel } from '../../models/video/video-playlist'
2017-12-12 17:53:50 +01:00
import { VideoShareModel } from '../../models/video/video-share'
import { activityPubResponse } from './utils'
2017-11-09 17:51:58 +01:00
const activityPubClientRouter = express.Router()
2020-04-10 15:52:01 +02:00
activityPubClientRouter.use(cors())
2017-11-09 17:51:58 +01:00
2020-02-04 16:14:33 +01:00
// Intercept ActivityPub client requests
activityPubClientRouter.get(
[ '/accounts?/:name', '/accounts?/:name/video-channels' ],
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localAccountValidator),
accountController
2017-11-09 17:51:58 +01:00
)
2018-01-15 09:46:46 +01:00
activityPubClientRouter.get('/accounts?/:name/followers',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localAccountValidator),
asyncMiddleware(accountFollowersController)
2017-11-09 17:51:58 +01:00
)
2018-01-15 09:46:46 +01:00
activityPubClientRouter.get('/accounts?/:name/following',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localAccountValidator),
asyncMiddleware(accountFollowingController)
2017-11-09 17:51:58 +01:00
)
2019-02-26 10:55:40 +01:00
activityPubClientRouter.get('/accounts?/:name/playlists',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localAccountValidator),
asyncMiddleware(accountPlaylistsController)
2019-02-26 10:55:40 +01:00
)
2018-11-14 15:01:28 +01:00
activityPubClientRouter.get('/accounts?/:name/likes/:videoId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(getAccountVideoRateValidatorFactory('like')),
getAccountVideoRateFactory('like')
2018-11-14 15:01:28 +01:00
)
activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(getAccountVideoRateValidatorFactory('dislike')),
getAccountVideoRateFactory('dislike')
2018-11-14 15:01:28 +01:00
)
2017-11-09 17:51:58 +01:00
2017-11-16 15:22:39 +01:00
activityPubClientRouter.get('/videos/watch/:id',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)),
2019-03-19 09:34:29 +01:00
asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
asyncMiddleware(videoController)
)
activityPubClientRouter.get('/videos/watch/:id/activity',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
asyncMiddleware(videoController)
)
activityPubClientRouter.get('/videos/watch/:id/announces',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
2019-03-19 09:34:29 +01:00
asyncMiddleware(videoAnnouncesController)
)
2018-11-14 15:01:28 +01:00
activityPubClientRouter.get('/videos/watch/:id/announces/:actorId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videosShareValidator),
asyncMiddleware(videoAnnounceController)
2017-11-16 15:22:39 +01:00
)
activityPubClientRouter.get('/videos/watch/:id/likes',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
2019-03-19 09:34:29 +01:00
asyncMiddleware(videoLikesController)
)
activityPubClientRouter.get('/videos/watch/:id/dislikes',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
2019-03-19 09:34:29 +01:00
asyncMiddleware(videoDislikesController)
)
activityPubClientRouter.get('/videos/watch/:id/comments',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
2019-03-19 09:34:29 +01:00
asyncMiddleware(videoCommentsController)
)
2017-12-28 11:16:08 +01:00
activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videoCommentGetValidator),
asyncMiddleware(videoCommentController)
2017-12-28 11:16:08 +01:00
)
activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videoCommentGetValidator),
asyncMiddleware(videoCommentController)
)
2017-12-28 11:16:08 +01:00
activityPubClientRouter.get(
[ '/video-channels/:name', '/video-channels/:name/videos' ],
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localVideoChannelValidator),
2020-01-31 16:56:52 +01:00
videoChannelController
2017-11-16 15:22:39 +01:00
)
2018-08-17 15:45:42 +02:00
activityPubClientRouter.get('/video-channels/:name/followers',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localVideoChannelValidator),
asyncMiddleware(videoChannelFollowersController)
2018-01-15 09:46:46 +01:00
)
2018-08-17 15:45:42 +02:00
activityPubClientRouter.get('/video-channels/:name/following',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(localVideoChannelValidator),
asyncMiddleware(videoChannelFollowingController)
2018-01-15 09:46:46 +01:00
)
activityPubClientRouter.get('/video-channels/:name/playlists',
executeIfActivityPub,
asyncMiddleware(localVideoChannelValidator),
asyncMiddleware(videoChannelPlaylistsController)
)
2017-11-16 15:22:39 +01:00
2018-09-11 16:27:07 +02:00
activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videoFileRedundancyGetValidator),
asyncMiddleware(videoRedundancyController)
2019-01-29 08:37:25 +01:00
)
activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videoPlaylistRedundancyGetValidator),
asyncMiddleware(videoRedundancyController)
2018-09-11 16:27:07 +02:00
)
2019-02-26 10:55:40 +01:00
activityPubClientRouter.get('/video-playlists/:playlistId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
2019-08-15 11:53:26 +02:00
asyncMiddleware(videoPlaylistsGetValidator('all')),
2019-03-19 09:34:29 +01:00
asyncMiddleware(videoPlaylistController)
2019-02-26 10:55:40 +01:00
)
activityPubClientRouter.get('/video-playlists/:playlistId/videos/:playlistElementId',
2019-03-19 09:34:29 +01:00
executeIfActivityPub,
asyncMiddleware(videoPlaylistElementAPGetValidator),
2020-01-31 16:56:52 +01:00
videoPlaylistElementController
2019-02-26 10:55:40 +01:00
)
2017-11-09 17:51:58 +01:00
// ---------------------------------------------------------------------------
export {
activityPubClientRouter
}
// ---------------------------------------------------------------------------
2019-02-26 10:55:40 +01:00
function accountController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const account = res.locals.account
2017-11-09 17:51:58 +01:00
return activityPubResponse(activityPubContextify(account.toActivityPubObject()), res)
2017-11-09 17:51:58 +01:00
}
2019-02-26 10:55:40 +01:00
async function accountFollowersController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const account = res.locals.account
2018-01-15 09:46:46 +01:00
const activityPubResult = await actorFollowers(req, account.Actor)
2017-11-09 17:51:58 +01:00
return activityPubResponse(activityPubContextify(activityPubResult), res)
2017-11-09 17:51:58 +01:00
}
2019-02-26 10:55:40 +01:00
async function accountFollowingController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const account = res.locals.account
2018-01-15 09:46:46 +01:00
const activityPubResult = await actorFollowing(req, account.Actor)
2017-11-09 17:51:58 +01:00
return activityPubResponse(activityPubContextify(activityPubResult), res)
2017-11-09 17:51:58 +01:00
}
2017-11-16 15:22:39 +01:00
2019-02-26 10:55:40 +01:00
async function accountPlaylistsController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const account = res.locals.account
const activityPubResult = await actorPlaylists(req, { account })
return activityPubResponse(activityPubContextify(activityPubResult), res)
}
async function videoChannelPlaylistsController (req: express.Request, res: express.Response) {
const channel = res.locals.videoChannel
const activityPubResult = await actorPlaylists(req, { channel })
2019-02-26 10:55:40 +01:00
return activityPubResponse(activityPubContextify(activityPubResult), res)
}
function getAccountVideoRateFactory (rateType: VideoRateType) {
2018-11-14 15:01:28 +01:00
return (req: express.Request, res: express.Response) => {
2019-03-19 10:35:15 +01:00
const accountVideoRate = res.locals.accountVideoRate
2018-11-14 15:01:28 +01:00
const byActor = accountVideoRate.Account.Actor
const APObject = rateType === 'like'
2020-11-20 11:21:08 +01:00
? buildLikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video)
: buildDislikeActivity(accountVideoRate.url, byActor, accountVideoRate.Video)
2018-11-14 15:01:28 +01:00
return activityPubResponse(activityPubContextify(APObject), res)
}
}
2018-11-30 15:06:06 +01:00
async function videoController (req: express.Request, res: express.Response) {
2019-01-29 08:37:25 +01:00
// We need more attributes
2020-11-02 15:43:44 +01:00
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(res.locals.onlyVideoWithRights.id)
2017-11-16 15:22:39 +01:00
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(video.url, res)) return
2018-11-16 11:18:13 +01:00
2018-07-12 19:02:00 +02:00
// We need captions to render AP object
2019-08-15 11:53:26 +02:00
const captions = await VideoCaptionModel.listVideoCaptions(video.id)
2019-08-21 14:31:57 +02:00
const videoWithCaptions = Object.assign(video, { VideoCaptions: captions })
2018-07-12 19:02:00 +02:00
2019-08-15 11:53:26 +02:00
const audience = getAudience(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === VideoPrivacy.PUBLIC)
const videoObject = audiencify(videoWithCaptions.toActivityPubObject(), audience)
2018-01-10 17:18:12 +01:00
if (req.path.endsWith('/activity')) {
2019-08-15 11:53:26 +02:00
const data = buildCreateActivity(videoWithCaptions.url, video.VideoChannel.Account.Actor, videoObject, audience)
return activityPubResponse(activityPubContextify(data), res)
}
return activityPubResponse(activityPubContextify(videoObject), res)
2017-11-16 15:22:39 +01:00
}
2018-11-30 15:06:06 +01:00
async function videoAnnounceController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const share = res.locals.videoShare
2018-11-16 11:18:13 +01:00
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(share.url, res)) return
2018-11-16 11:18:13 +01:00
2019-08-15 11:53:26 +02:00
const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll, undefined)
return activityPubResponse(activityPubContextify(activity, 'Announce'), res)
}
2018-11-30 15:06:06 +01:00
async function videoAnnouncesController (req: express.Request, res: express.Response) {
const video = res.locals.onlyImmutableVideo
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(video.url, res)) return
const handler = async (start: number, count: number) => {
const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count)
return {
total: result.count,
data: result.rows.map(r => r.url)
}
}
2020-11-20 11:21:08 +01:00
const json = await activityPubCollectionPagination(getLocalVideoSharesActivityPubUrl(video), handler, req.query.page)
return activityPubResponse(activityPubContextify(json), res)
}
2018-11-30 15:06:06 +01:00
async function videoLikesController (req: express.Request, res: express.Response) {
const video = res.locals.onlyImmutableVideo
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(video.url, res)) return
const json = await videoRates(req, 'like', video, getLocalVideoLikesActivityPubUrl(video))
return activityPubResponse(activityPubContextify(json), res)
}
2018-11-30 15:06:06 +01:00
async function videoDislikesController (req: express.Request, res: express.Response) {
const video = res.locals.onlyImmutableVideo
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(video.url, res)) return
const json = await videoRates(req, 'dislike', video, getLocalVideoDislikesActivityPubUrl(video))
return activityPubResponse(activityPubContextify(json), res)
}
2018-11-30 15:06:06 +01:00
async function videoCommentsController (req: express.Request, res: express.Response) {
const video = res.locals.onlyImmutableVideo
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(video.url, res)) return
const handler = async (start: number, count: number) => {
const result = await VideoCommentModel.listAndCountByVideoForAP(video, start, count)
return {
total: result.count,
data: result.rows.map(r => r.url)
}
}
2020-11-20 11:21:08 +01:00
const json = await activityPubCollectionPagination(getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page)
return activityPubResponse(activityPubContextify(json), res)
}
2020-01-31 16:56:52 +01:00
function videoChannelController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const videoChannel = res.locals.videoChannel
2017-11-16 15:22:39 +01:00
return activityPubResponse(activityPubContextify(videoChannel.toActivityPubObject()), res)
2017-11-16 15:22:39 +01:00
}
2017-12-28 11:16:08 +01:00
2018-11-30 15:06:06 +01:00
async function videoChannelFollowersController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const videoChannel = res.locals.videoChannel
2018-01-15 09:46:46 +01:00
const activityPubResult = await actorFollowers(req, videoChannel.Actor)
return activityPubResponse(activityPubContextify(activityPubResult), res)
2018-01-15 09:46:46 +01:00
}
2018-11-30 15:06:06 +01:00
async function videoChannelFollowingController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const videoChannel = res.locals.videoChannel
2018-01-15 09:46:46 +01:00
const activityPubResult = await actorFollowing(req, videoChannel.Actor)
return activityPubResponse(activityPubContextify(activityPubResult), res)
2018-01-15 09:46:46 +01:00
}
2018-11-30 15:06:06 +01:00
async function videoCommentController (req: express.Request, res: express.Response) {
2019-08-15 11:53:26 +02:00
const videoComment = res.locals.videoCommentFull
2017-12-28 11:16:08 +01:00
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(videoComment.url, res)) return
2018-11-16 11:18:13 +01:00
2018-01-05 11:19:25 +01:00
const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined)
2018-01-26 11:44:08 +01:00
const isPublic = true // Comments are always public
let videoCommentObject = videoComment.toActivityPubObject(threadParentComments)
2018-01-26 11:44:08 +01:00
if (videoComment.Account) {
const audience = getAudience(videoComment.Account.Actor, isPublic)
videoCommentObject = audiencify(videoCommentObject, audience)
2018-01-26 11:44:08 +01:00
if (req.path.endsWith('/activity')) {
const data = buildCreateActivity(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience)
return activityPubResponse(activityPubContextify(data), res)
}
}
return activityPubResponse(activityPubContextify(videoCommentObject), res)
2017-12-28 11:16:08 +01:00
}
2018-01-15 09:46:46 +01:00
2018-09-11 16:27:07 +02:00
async function videoRedundancyController (req: express.Request, res: express.Response) {
2019-03-19 10:35:15 +01:00
const videoRedundancy = res.locals.videoRedundancy
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(videoRedundancy.url, res)) return
2018-11-16 11:18:13 +01:00
2018-09-11 16:27:07 +02:00
const serverActor = await getServerActor()
const audience = getAudience(serverActor)
const object = audiencify(videoRedundancy.toActivityPubObject(), audience)
if (req.path.endsWith('/activity')) {
const data = buildCreateActivity(videoRedundancy.url, serverActor, object, audience)
2020-02-04 16:34:46 +01:00
return activityPubResponse(activityPubContextify(data, 'CacheFile'), res)
2018-09-11 16:27:07 +02:00
}
2020-02-04 16:34:46 +01:00
return activityPubResponse(activityPubContextify(object, 'CacheFile'), res)
2018-09-11 16:27:07 +02:00
}
2019-02-26 10:55:40 +01:00
async function videoPlaylistController (req: express.Request, res: express.Response) {
2019-08-15 11:53:26 +02:00
const playlist = res.locals.videoPlaylistFull
2019-02-26 10:55:40 +01:00
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(playlist.url, res)) return
2019-03-05 10:58:44 +01:00
// We need more attributes
playlist.OwnerAccount = await AccountModel.load(playlist.ownerAccountId)
const json = await playlist.toActivityPubObject(req.query.page, null)
2019-02-26 10:55:40 +01:00
const audience = getAudience(playlist.OwnerAccount.Actor, playlist.privacy === VideoPlaylistPrivacy.PUBLIC)
const object = audiencify(json, audience)
return activityPubResponse(activityPubContextify(object), res)
}
2020-01-31 16:56:52 +01:00
function videoPlaylistElementController (req: express.Request, res: express.Response) {
2019-08-21 14:31:57 +02:00
const videoPlaylistElement = res.locals.videoPlaylistElementAP
2019-02-26 10:55:40 +01:00
2020-11-20 11:21:08 +01:00
if (redirectIfNotOwned(videoPlaylistElement.url, res)) return
2019-02-26 10:55:40 +01:00
const json = videoPlaylistElement.toActivityPubObject()
return activityPubResponse(activityPubContextify(json), res)
}
2018-01-15 09:46:46 +01:00
// ---------------------------------------------------------------------------
2019-08-15 11:53:26 +02:00
async function actorFollowing (req: express.Request, actor: MActorId) {
const handler = (start: number, count: number) => {
return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count)
}
2018-01-15 09:46:46 +01:00
2019-04-11 11:33:44 +02:00
return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
2018-01-15 09:46:46 +01:00
}
2019-08-15 11:53:26 +02:00
async function actorFollowers (req: express.Request, actor: MActorId) {
const handler = (start: number, count: number) => {
2019-02-26 10:55:40 +01:00
return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count)
}
2019-04-11 11:33:44 +02:00
return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
2019-02-26 10:55:40 +01:00
}
async function actorPlaylists (req: express.Request, options: { account: MAccountId } | { channel: MChannelId }) {
2019-02-26 10:55:40 +01:00
const handler = (start: number, count: number) => {
return VideoPlaylistModel.listPublicUrlsOfForAP(options, start, count)
}
2018-01-15 09:46:46 +01:00
2019-04-11 11:33:44 +02:00
return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
2018-01-15 09:46:46 +01:00
}
function videoRates (req: express.Request, rateType: VideoRateType, video: MVideoId, url: string) {
const handler = async (start: number, count: number) => {
const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count)
return {
total: result.count,
2018-11-14 15:01:28 +01:00
data: result.rows.map(r => r.url)
}
}
return activityPubCollectionPagination(url, handler, req.query.page)
}
2020-11-20 11:21:08 +01:00
function redirectIfNotOwned (url: string, res: express.Response) {
if (url.startsWith(WEBSERVER.URL) === false) {
res.redirect(url)
return true
}
return false
}