import * as Episode from './Episode';
import Round from './Round';
+export const hasGlobalRole = (user, role) =>
+ user && role && user.global_roles && user.global_roles.includes(role);
+
export const isAdmin = user => user && user.role === 'admin';
export const isSameUser = (user, subject) => user && subject && user.id === subject.id;
user && channel && user.channel_crews &&
user.channel_crews.find(c => c.role === 'admin' && c.channel_id === channel.id);
+// Content
+
+export const mayEditContent = user =>
+ user && hasGlobalRole(user, 'content');
+
// Episodes
export const isCommentator = (user, episode) => {
isTournamentMonitor(user, tournament) ||
Round.isComplete(tournament, round);
+// Twitch
+
+export const mayManageTwitchBot = user => isAdmin(user) || hasGlobalRole(user, 'twitch');
+
// Users
export const mayEditNickname = (user, subject) =>