Merge pull request #780 from amyspark/find-pleroma-accounts
Improve searching accounts with Pleroma/MastoFE
This commit is contained in:
commit
55cb48a0a1
|
@ -40,12 +40,16 @@ const AccountProfile = {
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
return client.get('/search', { q: parsedAccount.acct, resolve: true })
|
return client.get('/search', { q: parsedAccount.url, resolve: true })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.data.accounts.length <= 0) throw new AccountNotFound('empty result')
|
if (res.data.accounts.length <= 0) throw new AccountNotFound('empty result')
|
||||||
const account = res.data.accounts.find(a => `@${a.acct}` === parsedAccount.acct)
|
const account = res.data.accounts.find(a => `@${a.acct}` === parsedAccount.acct)
|
||||||
if (account) return account
|
if (account) return account
|
||||||
const user = res.data.accounts.find(a => `@${a.username}@${rootState.TimelineSpace.account.domain}` === parsedAccount.acct)
|
const pleromaUser = res.data.accounts.find(a => a.acct === parsedAccount.acct)
|
||||||
|
if (pleromaUser) return pleromaUser
|
||||||
|
const localUser = res.data.accounts.find(a => `@${a.username}@${rootState.TimelineSpace.account.domain}` === parsedAccount.acct)
|
||||||
|
if (localUser) return localUser
|
||||||
|
const user = res.data.accounts.find(a => a.url === parsedAccount.url)
|
||||||
if (!user) throw new AccountNotFound('not found')
|
if (!user) throw new AccountNotFound('not found')
|
||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
|
|
|
@ -36,7 +36,11 @@ export function parseTag (tagURL) {
|
||||||
|
|
||||||
export function findAccount (target, parentClass = 'toot') {
|
export function findAccount (target, parentClass = 'toot') {
|
||||||
if (target.getAttribute('class') && target.getAttribute('class').includes('u-url')) {
|
if (target.getAttribute('class') && target.getAttribute('class').includes('u-url')) {
|
||||||
return parseMastodonAccount(target.href)
|
if (target.href && target.href.match(/^https:\/\/[a-zA-Z0-9-.]+\/users\/[a-zA-Z0-9-_.]+/)) {
|
||||||
|
return parsePleromaAccount(target.href)
|
||||||
|
} else {
|
||||||
|
return parseMastodonAccount(target.href)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// In Pleroma, link does not have class.
|
// In Pleroma, link does not have class.
|
||||||
// So we have to check URL.
|
// So we have to check URL.
|
||||||
|
@ -62,7 +66,8 @@ export function parseMastodonAccount (accountURL) {
|
||||||
const accountName = res[2]
|
const accountName = res[2]
|
||||||
return {
|
return {
|
||||||
username: accountName,
|
username: accountName,
|
||||||
acct: `${accountName}@${domainName}`
|
acct: `${accountName}@${domainName}`,
|
||||||
|
url: accountURL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +77,7 @@ export function parsePleromaAccount (accountURL) {
|
||||||
const accountName = res[2]
|
const accountName = res[2]
|
||||||
return {
|
return {
|
||||||
username: `@${accountName}`,
|
username: `@${accountName}`,
|
||||||
acct: `@${accountName}@${domainName}`
|
acct: `@${accountName}@${domainName}`,
|
||||||
|
url: accountURL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue