File size: 570 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// @flow
import type { GraphQLContext } from '../../';
import type { DBChannel } from 'shared/types';
import { getModeratorsInChannel } from '../../models/usersChannels';
import { canViewChannel } from '../../utils/permissions';
export default async (channel: DBChannel, _: any, ctx: GraphQLContext) => {
const { loaders, user: currentUser } = ctx;
const { id, isPrivate } = channel;
if (isPrivate) {
if (!(await canViewChannel(currentUser, id, loaders))) return null;
}
return getModeratorsInChannel(id).then(users => loaders.user.loadMany(users));
};
|