Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
// @flow
import type { GraphQLContext } from '../..';
import UserError from '../../utils/UserError';
import {
toggleCommunityNoindex,
getCommunityById,
} from '../../models/community';
import {
isAuthedResolver as requireAuth,
canAdministerCommunity,
} from '../../utils/permissions';
type Input = {
communityId: string,
};
export default requireAuth(async (_: any, args: Input, ctx: GraphQLContext) => {
const { communityId } = args;
const { user, loaders } = ctx;
if (!(await canAdministerCommunity(user.id, communityId, loaders))) {
return new UserError("You don't have permission to do this.");
}
const community = await getCommunityById(communityId);
if (!community) {
return new UserError('This community does not exist.');
}
return toggleCommunityNoindex(communityId);
});