fix: user acct not respecting domain (#2088)

This commit is contained in:
patak 2023-05-10 14:19:50 +02:00 committed by GitHub
parent f28c90498b
commit 29f6a73de1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 5 deletions

View file

@ -43,7 +43,7 @@ export function fetchAccountById(id?: string | null): Promise<mastodon.v1.Accoun
const cached = cache.get(key)
if (cached)
return cached
const domain = currentInstance.value ? getInstanceDomain(currentInstance.value) : null
const domain = getInstanceDomainFromServer(server)
const promise = useMastoClient().v1.accounts.fetch(id)
.then((r) => {
if (r.acct && !r.acct.includes('@') && domain)
@ -59,12 +59,12 @@ export function fetchAccountById(id?: string | null): Promise<mastodon.v1.Accoun
export async function fetchAccountByHandle(acct: string): Promise<mastodon.v1.Account> {
const server = currentServer.value
const userId = currentUser.value?.account.id
const userAcct = acct.endsWith(`@${server}`) ? acct.slice(0, -server.length - 1) : acct
const domain = getInstanceDomainFromServer(server)
const userAcct = (domain && acct.endsWith(`@${domain}`)) ? acct.slice(0, -domain.length - 1) : acct
const key = `${server}:${userId}:account:${userAcct}`
const cached = cache.get(key)
if (cached)
return cached
const domain = currentInstance.value ? getInstanceDomain(currentInstance.value) : undefined
async function lookupAccount() {
const client = useMastoClient()