1
0
Fork 0

Simplify search video channel

This commit is contained in:
Chocobozzz 2021-11-16 13:52:46 +01:00
parent 3455c2656e
commit b3ed044ded
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -56,7 +56,7 @@ function searchVideoChannels (req: express.Request, res: express.Response) {
if (parts.length === 3 && parts[0].length === 0) parts.shift() if (parts.length === 3 && parts[0].length === 0) parts.shift()
const isWebfingerSearch = parts.length === 2 && parts.every(p => p && !p.includes(' ')) const isWebfingerSearch = parts.length === 2 && parts.every(p => p && !p.includes(' '))
if (isURISearch(search) || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res) if (isURISearch(search) || isWebfingerSearch) return searchVideoChannelURI(search, res)
// @username -> username to search in DB // @username -> username to search in DB
if (search.startsWith('@')) query.search = search.replace(/^@/, '') if (search.startsWith('@')) query.search = search.replace(/^@/, '')
@ -110,11 +110,11 @@ async function searchVideoChannelsDB (query: VideoChannelsSearchQueryAfterSaniti
return res.json(getFormattedObjects(resultList.data, resultList.total)) return res.json(getFormattedObjects(resultList.data, resultList.total))
} }
async function searchVideoChannelURI (search: string, isWebfingerSearch: boolean, res: express.Response) { async function searchVideoChannelURI (search: string, res: express.Response) {
let videoChannel: MChannelAccountDefault let videoChannel: MChannelAccountDefault
let uri = search let uri = search
if (isWebfingerSearch) { if (!isURISearch(search)) {
try { try {
uri = await loadActorUrlOrGetFromWebfinger(search) uri = await loadActorUrlOrGetFromWebfinger(search)
} catch (err) { } catch (err) {