import { VideoCaptionModel } from '../../models/video/video-caption'
import { videoRedundancyGetValidator } from '../../middlewares/validators/redundancy'
import { getServerActor } from '../../helpers/utils'
+import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
const activityPubClientRouter = express.Router()
async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) {
const video: VideoModel = res.locals.video
+ if (video.isOwned() === false) return res.redirect(video.url)
+
// We need captions to render AP object
video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id)
async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) {
const share = res.locals.videoShare as VideoShareModel
+
+ if (share.Actor.isOwned() === false) return res.redirect(share.url)
+
const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined)
return activityPubResponse(activityPubContextify(activity), res)
async function videoCommentController (req: express.Request, res: express.Response, next: express.NextFunction) {
const videoComment: VideoCommentModel = res.locals.videoComment
+ if (videoComment.isOwned() === false) return res.redirect(videoComment.url)
+
const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined)
const isPublic = true // Comments are always public
const audience = getAudience(videoComment.Account.Actor, isPublic)
}
async function videoRedundancyController (req: express.Request, res: express.Response) {
- const videoRedundancy = res.locals.videoRedundancy
+ const videoRedundancy: VideoRedundancyModel = res.locals.videoRedundancy
+ if (videoRedundancy.isOwned() === false) return res.redirect(videoRedundancy.url)
+
const serverActor = await getServerActor()
const audience = getAudience(serverActor)
logger.debug('No cached results for route %s.', req.originalUrl)
const sendSave = res.send.bind(res)
+ const redirectSave = res.redirect.bind(res)
res.send = (body) => {
if (res.statusCode >= 200 && res.statusCode < 400) {
return sendSave(body)
}
+ res.redirect = url => {
+ done()
+
+ return redirectSave(url)
+ }
+
return next()
}
userLogin
} from '../../utils'
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
+import { waitJobs } from '../../utils/server/jobs'
describe('Test user subscriptions API validators', function () {
const path = '/api/v1/users/me/subscriptions'
})
it('Should succeed with the correct parameters', async function () {
+ this.timeout(20000)
+
await makePostBodyRequest({
url: server.url,
path,
fields: { uri: 'user1_channel@localhost:9001' },
statusCodeExpected: 204
})
+
+ await waitJobs([ server ])
})
})