aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/search.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts
index 534305ba6..9a1e30b83 100644
--- a/server/controllers/api/search.ts
+++ b/server/controllers/api/search.ts
@@ -59,10 +59,12 @@ function searchVideoChannels (req: express.Request, res: express.Response) {
59 59
60 // Handle strings like @toto@example.com 60 // Handle strings like @toto@example.com
61 if (parts.length === 3 && parts[0].length === 0) parts.shift() 61 if (parts.length === 3 && parts[0].length === 0) parts.shift()
62 const isWebfingerSearch = parts.length === 2 && parts.every(p => p.indexOf(' ') === -1) 62 const isWebfingerSearch = parts.length === 2 && parts.every(p => p && p.indexOf(' ') === -1)
63 63
64 if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res) 64 if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res)
65 65
66 // @username -> username to search in DB
67 if (query.search.startsWith('@')) query.search = query.search.replace(/^@/, '')
66 return searchVideoChannelsDB(query, res) 68 return searchVideoChannelsDB(query, res)
67} 69}
68 70
@@ -85,7 +87,15 @@ async function searchVideoChannelURI (search: string, isWebfingerSearch: boolean
85 let videoChannel: VideoChannelModel 87 let videoChannel: VideoChannelModel
86 let uri = search 88 let uri = search
87 89
88 if (isWebfingerSearch) uri = await loadActorUrlOrGetFromWebfinger(search) 90 if (isWebfingerSearch) {
91 try {
92 uri = await loadActorUrlOrGetFromWebfinger(search)
93 } catch (err) {
94 logger.warn('Cannot load actor URL or get from webfinger.', { search, err })
95
96 return res.json({ total: 0, data: [] })
97 }
98 }
89 99
90 if (isUserAbleToSearchRemoteURI(res)) { 100 if (isUserAbleToSearchRemoteURI(res)) {
91 try { 101 try {