aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-20 11:21:08 +0100
committerChocobozzz <me@florianbigard.com>2020-11-20 11:21:08 +0100
commitde94ac86a211dec657332d964693857ec235ce40 (patch)
tree3bff96a40e7c862d83561a26249992b07331b0a2 /server/controllers/api
parent3fba4b6bce69247b1d37f923894d8f44818a891c (diff)
downloadPeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.gz
PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.zst
PeerTube-de94ac86a211dec657332d964693857ec235ce40.zip
Fix incorrect IDs in AP federation
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/server/follows.ts2
-rw-r--r--server/controllers/api/video-playlist.ts46
-rw-r--r--server/controllers/api/videos/import.ts4
-rw-r--r--server/controllers/api/videos/index.ts4
-rw-r--r--server/controllers/api/videos/live.ts4
-rw-r--r--server/controllers/api/videos/rate.ts6
6 files changed, 33 insertions, 33 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index 23823c9fb..517d1897e 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -165,7 +165,7 @@ async function removeFollowing (req: express.Request, res: express.Response) {
165async function removeOrRejectFollower (req: express.Request, res: express.Response) { 165async function removeOrRejectFollower (req: express.Request, res: express.Response) {
166 const follow = res.locals.follow 166 const follow = res.locals.follow
167 167
168 await sendReject(follow.ActorFollower, follow.ActorFollowing) 168 await sendReject(follow.url, follow.ActorFollower, follow.ActorFollowing)
169 169
170 await follow.destroy() 170 await follow.destroy()
171 171
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index 41a0e07ff..fb08a63b2 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -1,5 +1,24 @@
1import * as express from 'express' 1import * as express from 'express'
2import { join } from 'path'
3import { getServerActor } from '@server/models/application/application'
4import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
5import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
6import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model'
7import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model'
8import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
9import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model'
10import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model'
11import { resetSequelizeInstance } from '../../helpers/database-utils'
12import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils'
13import { logger } from '../../helpers/logger'
2import { getFormattedObjects } from '../../helpers/utils' 14import { getFormattedObjects } from '../../helpers/utils'
15import { CONFIG } from '../../initializers/config'
16import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants'
17import { sequelizeTypescript } from '../../initializers/database'
18import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send'
19import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url'
20import { JobQueue } from '../../lib/job-queue'
21import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail'
3import { 22import {
4 asyncMiddleware, 23 asyncMiddleware,
5 asyncRetryTransactionMiddleware, 24 asyncRetryTransactionMiddleware,
@@ -10,11 +29,6 @@ import {
10 setDefaultSort 29 setDefaultSort
11} from '../../middlewares' 30} from '../../middlewares'
12import { videoPlaylistsSortValidator } from '../../middlewares/validators' 31import { videoPlaylistsSortValidator } from '../../middlewares/validators'
13import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils'
14import { MIMETYPES, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers/constants'
15import { logger } from '../../helpers/logger'
16import { resetSequelizeInstance } from '../../helpers/database-utils'
17import { VideoPlaylistModel } from '../../models/video/video-playlist'
18import { 32import {
19 commonVideoPlaylistFiltersValidator, 33 commonVideoPlaylistFiltersValidator,
20 videoPlaylistsAddValidator, 34 videoPlaylistsAddValidator,
@@ -25,23 +39,9 @@ import {
25 videoPlaylistsUpdateOrRemoveVideoValidator, 39 videoPlaylistsUpdateOrRemoveVideoValidator,
26 videoPlaylistsUpdateValidator 40 videoPlaylistsUpdateValidator
27} from '../../middlewares/validators/videos/video-playlists' 41} from '../../middlewares/validators/videos/video-playlists'
28import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
29import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
30import { join } from 'path'
31import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send'
32import { getVideoPlaylistActivityPubUrl, getVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url'
33import { VideoPlaylistUpdate } from '../../../shared/models/videos/playlist/video-playlist-update.model'
34import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
35import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model'
36import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model'
37import { AccountModel } from '../../models/account/account' 42import { AccountModel } from '../../models/account/account'
38import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' 43import { VideoPlaylistModel } from '../../models/video/video-playlist'
39import { JobQueue } from '../../lib/job-queue' 44import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
40import { CONFIG } from '../../initializers/config'
41import { sequelizeTypescript } from '../../initializers/database'
42import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail'
43import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
44import { getServerActor } from '@server/models/application/application'
45 45
46const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) 46const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR })
47 47
@@ -161,7 +161,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
161 ownerAccountId: user.Account.id 161 ownerAccountId: user.Account.id
162 }) as MVideoPlaylistFull 162 }) as MVideoPlaylistFull
163 163
164 videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object 164 videoPlaylist.url = getLocalVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
165 165
166 if (videoPlaylistInfo.videoChannelId) { 166 if (videoPlaylistInfo.videoChannelId) {
167 const videoChannel = res.locals.videoChannel 167 const videoChannel = res.locals.videoChannel
@@ -304,7 +304,7 @@ async function addVideoInPlaylist (req: express.Request, res: express.Response)
304 videoId: video.id 304 videoId: video.id
305 }, { transaction: t }) 305 }, { transaction: t })
306 306
307 playlistElement.url = getVideoPlaylistElementActivityPubUrl(videoPlaylist, playlistElement) 307 playlistElement.url = getLocalVideoPlaylistElementActivityPubUrl(videoPlaylist, playlistElement)
308 await playlistElement.save({ transaction: t }) 308 await playlistElement.save({ transaction: t })
309 309
310 videoPlaylist.changed('updatedAt', true) 310 videoPlaylist.changed('updatedAt', true)
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 5840cd063..bc5fea7aa 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -28,7 +28,7 @@ import { getYoutubeDLInfo, getYoutubeDLSubs, YoutubeDLInfo } from '../../../help
28import { CONFIG } from '../../../initializers/config' 28import { CONFIG } from '../../../initializers/config'
29import { MIMETYPES } from '../../../initializers/constants' 29import { MIMETYPES } from '../../../initializers/constants'
30import { sequelizeTypescript } from '../../../initializers/database' 30import { sequelizeTypescript } from '../../../initializers/database'
31import { getVideoActivityPubUrl } from '../../../lib/activitypub/url' 31import { getLocalVideoActivityPubUrl } from '../../../lib/activitypub/url'
32import { JobQueue } from '../../../lib/job-queue/job-queue' 32import { JobQueue } from '../../../lib/job-queue/job-queue'
33import { createVideoMiniatureFromExisting, createVideoMiniatureFromUrl } from '../../../lib/thumbnail' 33import { createVideoMiniatureFromExisting, createVideoMiniatureFromUrl } from '../../../lib/thumbnail'
34import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 34import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
@@ -250,7 +250,7 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You
250 originallyPublishedAt: body.originallyPublishedAt || importData.originallyPublishedAt 250 originallyPublishedAt: body.originallyPublishedAt || importData.originallyPublishedAt
251 } 251 }
252 const video = new VideoModel(videoData) 252 const video = new VideoModel(videoData)
253 video.url = getVideoActivityPubUrl(video) 253 video.url = getLocalVideoActivityPubUrl(video)
254 254
255 return video 255 return video
256} 256}
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index bfebc54ed..b5ff2e72e 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -5,7 +5,7 @@ import toInt from 'validator/lib/toInt'
5import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' 5import { addOptimizeOrMergeAudioJob } from '@server/helpers/video'
6import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 6import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
7import { changeVideoChannelShare } from '@server/lib/activitypub/share' 7import { changeVideoChannelShare } from '@server/lib/activitypub/share'
8import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' 8import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
9import { LiveManager } from '@server/lib/live-manager' 9import { LiveManager } from '@server/lib/live-manager'
10import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' 10import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
11import { getVideoFilePath } from '@server/lib/video-paths' 11import { getVideoFilePath } from '@server/lib/video-paths'
@@ -189,7 +189,7 @@ async function addVideo (req: express.Request, res: express.Response) {
189 videoData.duration = videoPhysicalFile['duration'] // duration was added by a previous middleware 189 videoData.duration = videoPhysicalFile['duration'] // duration was added by a previous middleware
190 190
191 const video = new VideoModel(videoData) as MVideoFullLight 191 const video = new VideoModel(videoData) as MVideoFullLight
192 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object 192 video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
193 193
194 const videoFile = new VideoFileModel({ 194 const videoFile = new VideoFileModel({
195 extname: extname(videoPhysicalFile.filename), 195 extname: extname(videoPhysicalFile.filename),
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index d438b6f3a..a6f00c1bd 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid'
3import { createReqFiles } from '@server/helpers/express-utils' 3import { createReqFiles } from '@server/helpers/express-utils'
4import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
5import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' 5import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants'
6import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' 6import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
7import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' 7import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
8import { Hooks } from '@server/lib/plugins/hooks' 8import { Hooks } from '@server/lib/plugins/hooks'
9import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' 9import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
@@ -86,7 +86,7 @@ async function addLiveVideo (req: express.Request, res: express.Response) {
86 videoData.duration = 0 86 videoData.duration = 0
87 87
88 const video = new VideoModel(videoData) as MVideoDetails 88 const video = new VideoModel(videoData) as MVideoDetails
89 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object 89 video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
90 90
91 const videoLive = new VideoLiveModel() 91 const videoLive = new VideoLiveModel()
92 videoLive.saveReplay = videoInfo.saveReplay || false 92 videoLive.saveReplay = videoInfo.saveReplay || false
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 3ee365289..df1eddb4f 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { UserVideoRateUpdate } from '../../../../shared' 2import { UserVideoRateUpdate } from '../../../../shared'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { VIDEO_RATE_TYPES } from '../../../initializers/constants' 4import { VIDEO_RATE_TYPES } from '../../../initializers/constants'
5import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' 5import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates'
6import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' 6import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares'
7import { AccountModel } from '../../../models/account/account' 7import { AccountModel } from '../../../models/account/account'
8import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 8import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
@@ -52,7 +52,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
52 await previousRate.destroy(sequelizeOptions) 52 await previousRate.destroy(sequelizeOptions)
53 } else { // Update previous rate 53 } else { // Update previous rate
54 previousRate.type = rateType 54 previousRate.type = rateType
55 previousRate.url = getRateUrl(rateType, userAccount.Actor, videoInstance) 55 previousRate.url = getLocalRateUrl(rateType, userAccount.Actor, videoInstance)
56 await previousRate.save(sequelizeOptions) 56 await previousRate.save(sequelizeOptions)
57 } 57 }
58 } else if (rateType !== 'none') { // There was not a previous rate, insert a new one if there is a rate 58 } else if (rateType !== 'none') { // There was not a previous rate, insert a new one if there is a rate
@@ -60,7 +60,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
60 accountId: accountInstance.id, 60 accountId: accountInstance.id,
61 videoId: videoInstance.id, 61 videoId: videoInstance.id,
62 type: rateType, 62 type: rateType,
63 url: getRateUrl(rateType, userAccount.Actor, videoInstance) 63 url: getLocalRateUrl(rateType, userAccount.Actor, videoInstance)
64 } 64 }
65 65
66 await AccountVideoRateModel.create(query, sequelizeOptions) 66 await AccountVideoRateModel.create(query, sequelizeOptions)