]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/search/search-videos.ts
Merge branch 'release/5.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / controllers / api / search / search-videos.ts
index 6db70acdfdb00d2ce2479d3977c0bb45f49008b9..1d7a7b7bcea16cf6c2d3b020ffc35a9221f9b586 100644 (file)
@@ -1,7 +1,7 @@
 import express from 'express'
 import { sanitizeUrl } from '@server/helpers/core-utils'
 import { pickSearchVideoQuery } from '@server/helpers/query'
-import { doJSONRequest } from '@server/helpers/requests'
+import { doJSONRequest, findLatestRedirection } from '@server/helpers/requests'
 import { CONFIG } from '@server/initializers/config'
 import { WEBSERVER } from '@server/initializers/constants'
 import { getOrCreateAPVideo } from '@server/lib/activitypub/videos'
@@ -134,15 +134,17 @@ async function searchVideoURI (url: string, res: express.Response) {
   if (isUserAbleToSearchRemoteURI(res)) {
     try {
       const syncParam = {
-        likes: false,
-        dislikes: false,
+        rates: false,
         shares: false,
         comments: false,
         thumbnail: true,
         refreshVideo: false
       }
 
-      const result = await getOrCreateAPVideo({ videoObject: url, syncParam })
+      const result = await getOrCreateAPVideo({
+        videoObject: await findLatestRedirection(url, { activityPub: true }),
+        syncParam
+      })
       video = result ? result.video : undefined
     } catch (err) {
       logger.info('Cannot search remote video %s.', url, { err })