X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fwebfinger.ts;h=33367f651793fd3b053390e929d5f5f411162c9a;hb=2539932e16129992a2c0889b4ff527c265a8e2c7;hp=10fcec4622c9f1b6429cd0a048d6d28ab31cd1bc;hpb=f5b0af50c85e2f8b6b2b054ac1f47123cacbe08d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts index 10fcec462..33367f651 100644 --- a/server/helpers/webfinger.ts +++ b/server/helpers/webfinger.ts @@ -1,9 +1,10 @@ import * as WebFinger from 'webfinger.js' import { WebFingerData } from '../../shared' -import { ActorModel } from '../models/activitypub/actor' +import { WEBSERVER } from '../initializers/constants' +import { ActorModel } from '../models/actor/actor' +import { MActorFull } from '../types/models' import { isTestInstance } from './core-utils' import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' -import { CONFIG } from '../initializers' 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)