Compare hosts in findAccountByUsername, fixes #730

merge-requests/692/head^2
Alex Gleason 2021-10-07 14:43:14 -05:00
rodzic 079736e199
commit c3da48ebf4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 24 dodań i 2 usunięć

Wyświetl plik

@ -47,14 +47,36 @@ export const makeGetAccount = () => {
});
};
export const findAccountByUsername = (state, username) => {
const findAccountsByUsername = (state, username) => {
const accounts = state.get('accounts');
return accounts.find(account => {
return accounts.filter(account => {
return username.toLowerCase() === account.getIn(['acct'], '').toLowerCase();
});
};
export const findAccountByUsername = (state, username) => {
const accounts = findAccountsByUsername(state, username);
if (accounts.size > 1) {
const me = state.get('me');
const meURL = state.getIn(['accounts', me, 'url']);
return accounts.find(account => {
try {
// If more than one account has the same username, try matching its host
const { host } = new URL(account.get('url'));
const { host: meHost } = new URL(meURL);
return host === meHost;
} catch {
return false;
}
});
} else {
return accounts.first();
}
};
const toServerSideType = columnType => {
switch (columnType) {
case 'home':