mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-21 19:53:50 +01:00
Resolve actual subject host on createPerson
This commit is contained in:
parent
35f7bde1a4
commit
59571f2372
@ -48,6 +48,7 @@ import Resolver from "../resolver.js";
|
||||
import { extractApHashtags } from "./tag.js";
|
||||
import { resolveNote, extractEmojis } from "./note.js";
|
||||
import { resolveImage } from "./image.js";
|
||||
import { getSubjectHostFromUri } from "@/remote/resolve-user.js"
|
||||
|
||||
const logger = apLogger;
|
||||
|
||||
@ -184,7 +185,7 @@ export async function createPerson(
|
||||
|
||||
logger.info(`Creating the Person: ${person.id}`);
|
||||
|
||||
const host = subjectHost ?? toPuny(new URL(object.id).hostname);
|
||||
const host = subjectHost ?? await getSubjectHostFromUri(object.id) ?? toPuny(new URL(object.id).hostname);
|
||||
|
||||
const { fields } = analyzeAttachments(person.attachment || []);
|
||||
|
||||
|
@ -171,6 +171,22 @@ export async function resolveUser(
|
||||
return user;
|
||||
}
|
||||
|
||||
export async function getSubjectHostFromUri( uri: string): Promise<string | null> {
|
||||
try {
|
||||
const acct = subjectToAcct((await webFinger(uri)).subject);
|
||||
const res = await resolveUserWebFinger(acct.toLowerCase());
|
||||
const finalAcct = subjectToAcct(res.subject);
|
||||
const m = finalAcct.match(/^([^@]+)@(.*)/);
|
||||
if (!m) {
|
||||
return null;
|
||||
}
|
||||
return m[2];
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveUserWebFinger(acctLower: string, recurse: boolean = true): Promise<{
|
||||
subject: string,
|
||||
self: {
|
||||
|
Loading…
Reference in New Issue
Block a user