diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-17 10:12:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-17 10:13:54 +0200 |
commit | 2ff83ae2923aa93ccefb0fa989ae0bf138a46d77 (patch) | |
tree | 1b1578b4a38e6a0c939f5d47f62ffe43839a872e | |
parent | 743164fed1cbeeee0fd39e9848dbe5131b734e71 (diff) | |
download | PeerTube-2ff83ae2923aa93ccefb0fa989ae0bf138a46d77.tar.gz PeerTube-2ff83ae2923aa93ccefb0fa989ae0bf138a46d77.tar.zst PeerTube-2ff83ae2923aa93ccefb0fa989ae0bf138a46d77.zip |
Handle actors search beginning with '@'
Something like @toto@example.com
-rw-r--r-- | server/controllers/api/search.ts | 3 | ||||
-rw-r--r-- | server/helpers/webfinger.ts | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index 28a7a04ca..58851d0b5 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts | |||
@@ -56,6 +56,9 @@ function searchVideoChannels (req: express.Request, res: express.Response) { | |||
56 | const isURISearch = search.startsWith('http://') || search.startsWith('https://') | 56 | const isURISearch = search.startsWith('http://') || search.startsWith('https://') |
57 | 57 | ||
58 | const parts = search.split('@') | 58 | const parts = search.split('@') |
59 | |||
60 | // Handle strings like @toto@example.com | ||
61 | if (parts.length === 3 && parts[0].length === 0) parts.shift() | ||
59 | const isWebfingerSearch = parts.length === 2 && parts.every(p => p.indexOf(' ') === -1) | 62 | const isWebfingerSearch = parts.length === 2 && parts.every(p => p.indexOf(' ') === -1) |
60 | 63 | ||
61 | if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res) | 64 | if (isURISearch || isWebfingerSearch) return searchVideoChannelURI(search, isWebfingerSearch, res) |
diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts index 10fcec462..156376943 100644 --- a/server/helpers/webfinger.ts +++ b/server/helpers/webfinger.ts | |||
@@ -12,7 +12,10 @@ const webfinger = new WebFinger({ | |||
12 | request_timeout: 3000 | 12 | request_timeout: 3000 |
13 | }) | 13 | }) |
14 | 14 | ||
15 | async function loadActorUrlOrGetFromWebfinger (uri: string) { | 15 | async function loadActorUrlOrGetFromWebfinger (uriArg: string) { |
16 | // Handle strings like @toto@example.com | ||
17 | const uri = uriArg.startsWith('@') ? uriArg.slice(1) : uriArg | ||
18 | |||
16 | const [ name, host ] = uri.split('@') | 19 | const [ name, host ] = uri.split('@') |
17 | let actor: ActorModel | 20 | let actor: ActorModel |
18 | 21 | ||