Let isStaff accept an undefined value
This commit is contained in:
@@ -54,4 +54,11 @@ describe('isStaff', () => {
|
|||||||
expect(isStaff(mod)).toBe(true);
|
expect(isStaff(mod)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('with undefined', () => {
|
||||||
|
const account = undefined;
|
||||||
|
it('returns false', () => {
|
||||||
|
expect(isStaff(account)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
|
|
||||||
export const getDomain = account => {
|
export const getDomain = account => {
|
||||||
let re = /https?:\/\/(.*?)\//i;
|
let re = /https?:\/\/(.*?)\//i;
|
||||||
return re.exec(account.get('url'))[1];
|
return re.exec(account.get('url'))[1];
|
||||||
@@ -15,7 +17,7 @@ export const acctFull = account => {
|
|||||||
return [user, domain].join('@');
|
return [user, domain].join('@');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isStaff = account => {
|
export const isStaff = (account = ImmutableMap()) => {
|
||||||
return ['is_admin', 'is_moderator'].some(key => (
|
return ['is_admin', 'is_moderator'].some(key => (
|
||||||
account.getIn(['pleroma', key]) === true
|
account.getIn(['pleroma', key]) === true
|
||||||
));
|
));
|
||||||
|
|||||||
Reference in New Issue
Block a user