X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fwebfinger.ts;h=da7e880778a07e03abaebe93369f1e395dcfd466;hb=d223dca0cd50010d1c4455e5eec1736b1c591aed;hp=10fcec4622c9f1b6429cd0a048d6d28ab31cd1bc;hpb=f5b0af50c85e2f8b6b2b054ac1f47123cacbe08d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts index 10fcec462..da7e88077 100644 --- a/server/helpers/webfinger.ts +++ b/server/helpers/webfinger.ts @@ -3,7 +3,8 @@ import { WebFingerData } from '../../shared' import { ActorModel } from '../models/activitypub/actor' import { isTestInstance } from './core-utils' import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' -import { CONFIG } from '../initializers' +import { WEBSERVER } from '../initializers/constants' +import { MActorFull } from '../types/models' const webfinger = new WebFinger({ webfist_fallback: false, @@ -12,11 +13,14 @@ const webfinger = new WebFinger({ request_timeout: 3000 }) -async function loadActorUrlOrGetFromWebfinger (uri: string) { +async function loadActorUrlOrGetFromWebfinger (uriArg: string) { + // Handle strings like @toto@example.com + const uri = uriArg.startsWith('@') ? uriArg.slice(1) : uriArg + const [ name, host ] = uri.split('@') - let actor: ActorModel + let actor: MActorFull - if (host === CONFIG.WEBSERVER.HOST) { + if (!host || host === WEBSERVER.HOST) { actor = await ActorModel.loadLocalByName(name) } else { actor = await ActorModel.loadByNameAndHost(name, host)