ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix fetching client comment URL
Chocobozzza8bc342204b8
diff --git a/packages/tests/src/api/activitypub/client.ts b/packages/tests/src/api/activitypub/client.tsindex fb9575d31d..3692129952 100644--- a/packages/tests/src/api/activitypub/client.ts+++ b/packages/tests/src/api/activitypub/client.ts@@ -2,7 +2,7 @@import { expect } from 'chai'import { processViewersStats } from '@tests/shared/views.js'-import { HttpStatusCode, VideoPlaylistPrivacy, WatchActionObject } from '@peertube/peertube-models'+import { HttpStatusCode, VideoComment, VideoPlaylistPrivacy, WatchActionObject } from '@peertube/peertube-models'import {cleanupTests,createMultipleServers,@@ -17,6 +17,7 @@ describe('Test activitypub', function () {let servers: PeerTubeServer[] = []let video: { id: number, uuid: string, shortUUID: string }let playlist: { id: number, uuid: string, shortUUID: string }+ let comment: VideoCommentasync function testAccount (path: string) {const res = await makeActivityPubGetRequest(servers[0].url, path)@@ -47,6 +48,18 @@ describe('Test activitypub', function () {expect(object.name).to.equal('video')}+ async function testComment (path: string) {+ const res = await makeActivityPubGetRequest(servers[0].url, path)+ const object = res.body++ expect(object.type).to.equal('Note')+ expect(object.id).to.equal(servers[0].url + '/videos/watch/' + video.uuid + '/comments/' + comment.id)+ expect(object.content).to.contain('thread')+ expect(object.inReplyTo).to.contain(servers[0].url + '/videos/watch/' + video.uuid)+ expect(object.attributedTo).to.equal(servers[0].url + '/accounts/root')+ expect(object.replyApproval).to.equal(servers[0].url + '/videos/watch/' + video.uuid + '/comments/' + comment.id + '/approve-reply')+ }+async function testPlaylist (path: string) {const res = await makeActivityPubGetRequest(servers[0].url, path)const object = res.body@@ -73,6 +86,8 @@ describe('Test activitypub', function () {playlist = await servers[0].playlists.create({ attributes })}+ comment = await servers[0].comments.createThread({ text: 'thread', videoId: video.id })+await doubleFollow(servers[0], servers[1])})@@ -86,6 +101,13 @@ describe('Test activitypub', function () {await testChannel('/c/root_channel')})+ it('Should return the video comment object', async function () {+ await testComment('/videos/watch/' + video.id + '/comments/' + comment.id)+ await testComment('/videos/watch/' + video.uuid + '/comments/' + comment.id)+ await testComment('/videos/watch/' + video.shortUUID + '/comments/' + comment.id)+ await testComment('/w/' + video.shortUUID + ';threadId=' + comment.id)+ })+it('Should return the video object', async function () {await testVideo('/videos/watch/' + video.id)await testVideo('/videos/watch/' + video.uuid)diff --git a/server/core/controllers/activitypub/client.ts b/server/core/controllers/activitypub/client.tsindex eb87700742..0161ac0049 100644--- a/server/core/controllers/activitypub/client.ts+++ b/server/core/controllers/activitypub/client.ts@@ -104,6 +104,36 @@ activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId',asyncMiddleware(getAccountVideoRateFactory('dislike')))+// ---------------------------------------------------------------------------++activityPubClientRouter.get('/videos/watch/:id/comments',+ executeIfActivityPub,+ activityPubRateLimiter,+ asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),+ asyncMiddleware(videoCommentsController)+)+activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/approve-reply',+ executeIfActivityPub,+ activityPubRateLimiter,+ asyncMiddleware(videoCommentGetValidator),+ asyncMiddleware(videoCommentApprovedController)+)+activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity',+ executeIfActivityPub,+ activityPubRateLimiter,+ asyncMiddleware(videoCommentGetValidator),+ asyncMiddleware(videoCommentController)+)+activityPubClientRouter.get(+ [ '/videos/watch/:videoId/comments/:commentId', '/w/:videoId([^;]+);threadId=:commentId([0-9]+)' ],+ executeIfActivityPub,+ activityPubRateLimiter,+ asyncMiddleware(videoCommentGetValidator),+ asyncMiddleware(videoCommentController)+)++// ---------------------------------------------------------------------------+activityPubClientRouter.get([ '/videos/watch/:id', '/w/:id' ],executeIfActivityPub,@@ -145,33 +175,6 @@ activityPubClientRouter.get('/videos/watch/:id/dislikes',// ----------------------------------------------------------------------------activityPubClientRouter.get('/videos/watch/:id/comments',- executeIfActivityPub,- activityPubRateLimiter,- asyncMiddleware(videosCustomGetValidator('only-video-and-blacklist')),- asyncMiddleware(videoCommentsController)-)-activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/approve-reply',- executeIfActivityPub,- activityPubRateLimiter,- asyncMiddleware(videoCommentGetValidator),- asyncMiddleware(videoCommentApprovedController)-)-activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity',- executeIfActivityPub,- activityPubRateLimiter,- asyncMiddleware(videoCommentGetValidator),- asyncMiddleware(videoCommentController)-)-activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId',- executeIfActivityPub,- activityPubRateLimiter,- asyncMiddleware(videoCommentGetValidator),- asyncMiddleware(videoCommentController)-)--// ----------------------------------------------------------------------------const { middleware: chaptersCacheRouteMiddleware, instance: chaptersApiCache } = cacheRouteFactory()InternalEventEmitter.Instance.on('chapters-updated', ({ video }) => {