diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index d95e7cac9..f408e7932 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts @@ -39,8 +39,9 @@ export { searchRouter } function searchVideos (req: express.Request, res: express.Response) { const query: VideosSearchQuery = req.query - if (query.search.startsWith('http://') || query.search.startsWith('https://')) { - return searchVideoUrl(query.search, res) + const search = query.search + if (search && (search.startsWith('http://') || search.startsWith('https://'))) { + return searchVideoUrl(search, res) } return searchVideosDB(query, res) diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index cd709cd3f..46b63c5e9 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -112,7 +112,7 @@ const JOB_TTL: { [ id in JobType ]: number } = { 'email': 60000 * 10 // 10 minutes } const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job -const CRAWL_REQUEST_CONCURRENCY = 5 // How many requests in parallel to fetch remote data (likes, shares...) +const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index 7fdef008c..5cfb81fc7 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts @@ -1,5 +1,4 @@ import 'multer' -import * as uuidv4 from 'uuid' import { sendUpdateActor } from './activitypub/send' import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers' import { updateActorAvatarInstance } from './activitypub' @@ -15,7 +14,7 @@ async function updateActorAvatarFile ( accountOrChannel: AccountModel | VideoChannelModel ) { const extension = extname(avatarPhysicalFile.filename) - const avatarName = uuidv4() + extension + const avatarName = actor.uuid + extension const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) await processImage(avatarPhysicalFile, destination, AVATARS_SIZE) diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 5975985a1..44645b0e2 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -28,7 +28,6 @@ describe('Test video imports API validator', function () { let userAccessToken = '' let accountName: string let channelId: number - let channelUUID: string // --------------------------------------------------------------- @@ -49,7 +48,6 @@ describe('Test video imports API validator', function () { { const res = await getMyUserInformation(server.url, server.accessToken) channelId = res.body.videoChannels[ 0 ].id - channelUUID = res.body.videoChannels[ 0 ].uuid accountName = res.body.account.name + '@' + res.body.account.host } }) diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 575e04546..b67072851 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts @@ -27,6 +27,7 @@ describe('Test users with multiple servers', function () { let servers: ServerInfo[] = [] let user: User let userAccountName: string + let userAccountUUID: string let userVideoChannelUUID: string let userId: number let videoUUID: string @@ -62,7 +63,9 @@ describe('Test users with multiple servers', function () { { const res = await getMyUserInformation(servers[0].url, userAccessToken) - userAccountName = res.body.account.name + '@' + res.body.account.host + const account: Account = res.body.account + userAccountName = account.name + '@' + account.host + userAccountUUID = account.uuid } { @@ -196,7 +199,7 @@ describe('Test users with multiple servers', function () { it('Should not have actor files', async () => { for (const server of servers) { - await checkActorFilesWereRemoved(userAccountName, server.serverNumber) + await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) } }) diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index 370e69d2a..891148b07 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -34,7 +34,7 @@ describe('Test video NSFW policy', function () { return getMyUserInformation(server.url, server.accessToken) .then(res => { const user: User = res.body - const videoChannelUUID = user.videoChannels[0].uuid + const videoChannelName = user.videoChannels[0].name const accountName = user.account.name + '@' + user.account.host if (token) { @@ -42,7 +42,7 @@ describe('Test video NSFW policy', function () { getVideosListWithToken(server.url, token, query), searchVideoWithToken(server.url, 'n', token, query), getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), - getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5, undefined, query) + getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) ]) } @@ -50,7 +50,7 @@ describe('Test video NSFW policy', function () { getVideosList(server.url), searchVideo(server.url, 'n'), getAccountVideos(server.url, undefined, accountName, 0, 5), - getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5) + getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) ]) }) } diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 7f54c0e70..b89e72ab7 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -94,9 +94,9 @@ describe('Test update host scripts', function () { expect(res.body.total).to.equal(3) for (const channel of res.body.data) { - const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.uuid) + const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name) - expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.uuid) + expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name) } })