File size: 523 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// @flow
import type { DBCommunity } from 'shared/types';
import type { GraphQLContext } from '../../';
import { canModerateCommunity } from '../../utils/permissions';

export default async ({ id }: DBCommunity, _: any, ctx: GraphQLContext) => {
  const { user: currentUser, loaders } = ctx;

  if (!currentUser) return null;

  if (!(await canModerateCommunity(currentUser.id, id, loaders))) {
    return null;
  }

  return loaders.communitySettings.load(id).then(settings => {
    return settings.joinSettings;
  });
};