2020-04-21 14:00:31 -05:00
|
|
|
import { Map as ImmutableMap } from 'immutable';
|
|
|
|
|
2020-04-18 14:18:04 -05:00
|
|
|
export const getDomain = account => {
|
2020-03-28 13:07:36 -05:00
|
|
|
let re = /https?:\/\/(.*?)\//i;
|
|
|
|
return re.exec(account.get('url'))[1];
|
2020-04-14 13:44:40 -05:00
|
|
|
};
|
2020-03-28 13:07:36 -05:00
|
|
|
|
|
|
|
// user@domain even for local users
|
|
|
|
export const acctFull = account => {
|
|
|
|
let [user, domain] = account.get('acct').split('@');
|
|
|
|
try {
|
|
|
|
if (!domain) domain = getDomain(account);
|
|
|
|
} catch(e) {
|
2020-03-28 15:10:35 -05:00
|
|
|
console.warning('Could not get domain for acctFull. Falling back to acct.');
|
2020-03-28 13:07:36 -05:00
|
|
|
return account.get('acct');
|
|
|
|
}
|
|
|
|
return [user, domain].join('@');
|
2020-04-14 13:44:40 -05:00
|
|
|
};
|
2020-04-18 15:09:54 -05:00
|
|
|
|
2020-04-27 15:05:07 -05:00
|
|
|
export const isStaff = (account = ImmutableMap()) => (
|
|
|
|
[isAdmin, isModerator].some(f => f(account) === true)
|
|
|
|
);
|
|
|
|
|
|
|
|
export const isAdmin = account => (
|
|
|
|
account.getIn(['pleroma', 'is_admin']) === true
|
|
|
|
);
|
|
|
|
|
|
|
|
export const isModerator = account => (
|
|
|
|
account.getIn(['pleroma', 'is_moderator']) === true
|
|
|
|
);
|