Add isStaff utility

merge-requests/1/head
Alex Gleason 2020-04-18 15:09:54 -05:00
rodzic d3bef7038d
commit c6b9968855
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 30 dodań i 1 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
import { getDomain, acctFull } from '../accounts';
import { getDomain, acctFull, isStaff } from '../accounts';
import { fromJS } from 'immutable';
describe('getDomain', () => {
@ -32,3 +32,26 @@ describe('acctFull', () => {
});
});
});
describe('isStaff', () => {
describe('with empty user', () => {
const account = fromJS({});
it('returns false', () => {
expect(isStaff(account)).toBe(false);
});
});
describe('with Pleroma admin', () => {
const admin = fromJS({ pleroma: { is_admin: true } });
it('returns true', () => {
expect(isStaff(admin)).toBe(true);
});
});
describe('with Pleroma moderator', () => {
const mod = fromJS({ pleroma: { is_moderator: true } });
it('returns true', () => {
expect(isStaff(mod)).toBe(true);
});
});
});

Wyświetl plik

@ -14,3 +14,9 @@ export const acctFull = account => {
}
return [user, domain].join('@');
};
export const isStaff = account => {
return ['is_admin', 'is_moderator'].some(key => (
account.getIn(['pleroma', key]) === true
));
};