Mastodon: fall back to account lookup API

This commit is contained in:
Alex Gleason 2022-01-31 11:18:44 -06:00
parent 7e7ca52cca
commit 6e889c7a4f
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -156,14 +156,7 @@ export function fetchAccountByUsername(username) {
const features = getFeatures(instance);
const me = state.get('me');
if (!me && features.accountLookup) {
dispatch(accountLookup(username)).then(account => {
dispatch(fetchAccountSuccess(account));
}).catch(error => {
dispatch(fetchAccountFail(null, error));
dispatch(importErrorWhileFetchingAccountByUsername(username));
});
} else if (features.accountByUsername) {
if (features.accountByUsername && (me || !features.accountLookup)) {
api(getState).get(`/api/v1/accounts/${username}`).then(response => {
dispatch(fetchRelationships([response.data.id]));
dispatch(importFetchedAccount(response.data));
@ -172,6 +165,13 @@ export function fetchAccountByUsername(username) {
dispatch(fetchAccountFail(null, error));
dispatch(importErrorWhileFetchingAccountByUsername(username));
});
} else if (features.accountLookup) {
dispatch(accountLookup(username)).then(account => {
dispatch(fetchAccountSuccess(account));
}).catch(error => {
dispatch(fetchAccountFail(null, error));
dispatch(importErrorWhileFetchingAccountByUsername(username));
});
} else {
dispatch(accountSearch({
q: username,