mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-25 05:29:07 +01:00
Fix initial fetch of actual remote user host for remote gotosocial instances on createPerson, resolves #204
This commit is contained in:
parent
43f136c50f
commit
86defdffd3
@ -48,7 +48,11 @@ import Resolver from "../resolver.js";
|
||||
import { extractApHashtags } from "./tag.js";
|
||||
import { resolveNote, extractEmojis } from "./note.js";
|
||||
import { resolveImage } from "./image.js";
|
||||
import { getSubjectHostFromUri, getSubjectHostFromRemoteUser } from "@/remote/resolve-user.js"
|
||||
import {
|
||||
getSubjectHostFromUri,
|
||||
getSubjectHostFromRemoteUser,
|
||||
getSubjectHostFromAcctParts
|
||||
} from "@/remote/resolve-user.js"
|
||||
|
||||
const logger = apLogger;
|
||||
|
||||
@ -185,10 +189,12 @@ export async function createPerson(
|
||||
|
||||
logger.info(`Creating the Person: ${person.id}`);
|
||||
|
||||
const host = subjectHost ?? await getSubjectHostFromUri(object.id) ?? toPuny(new URL(object.id).hostname);
|
||||
|
||||
const usernameLower = person.preferredUsername?.toLowerCase();
|
||||
|
||||
const urlHostname = toPuny(new URL(object.id).hostname);
|
||||
|
||||
const host = subjectHost ?? await getSubjectHostFromUri(object.id) ?? await getSubjectHostFromAcctParts(usernameLower, urlHostname) ?? urlHostname;
|
||||
|
||||
if (usernameLower !== null) {
|
||||
let checkUser = (await Users.findOneBy({
|
||||
usernameLower: usernameLower,
|
||||
|
@ -207,6 +207,10 @@ export async function getSubjectHostFromRemoteUser(user: IRemoteUser | undefined
|
||||
return user ? getSubjectHostFromAcct(`${user.username}@${user.host}`) : null;
|
||||
}
|
||||
|
||||
export async function getSubjectHostFromAcctParts(username?: string | undefined, host?: string | undefined): Promise<string | null> {
|
||||
return username !== null && host !== null ? getSubjectHostFromAcct(`${username}@${host}`) : null;
|
||||
}
|
||||
|
||||
async function resolveUserWebFinger(acctLower: string, recurse: boolean = true): Promise<{
|
||||
subject: string,
|
||||
self: {
|
||||
|
Loading…
Reference in New Issue
Block a user