feat: support lookup account for gotosocial
This commit is contained in:
parent
20a90cc949
commit
2e7979817a
3 changed files with 28 additions and 5 deletions
|
@ -64,11 +64,22 @@ export async function fetchAccountByHandle(acct: string): Promise<mastodon.v1.Ac
|
|||
if (cached)
|
||||
return cached
|
||||
const domain = currentInstance.value?.uri
|
||||
const account = useMastoClient().v1.accounts.lookup({ acct })
|
||||
.then((r) => {
|
||||
if (r.acct && !r.acct.includes('@') && domain)
|
||||
r.acct = `${r.acct}@${domain}`
|
||||
|
||||
async function lookupAccount() {
|
||||
const client = useMastoClient()
|
||||
let account: mastodon.v1.Account
|
||||
if (!isGotoSocial.value)
|
||||
account = await client.v1.accounts.lookup({ acct })
|
||||
else
|
||||
account = (await client.v1.search({ q: `@${acct}`, type: 'accounts' })).accounts[0]
|
||||
|
||||
if (account.acct && !account.acct.includes('@') && domain)
|
||||
account.acct = `${account.acct}@${domain}`
|
||||
return account
|
||||
}
|
||||
|
||||
const account = lookupAccount()
|
||||
.then((r) => {
|
||||
cacheAccount(r, server, true)
|
||||
return r
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue