Download spectrum/api/mutations/community/toggleCommunityNoindex.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 820 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/mutations/community/toggleCommunityNoindex.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/mutations/community/toggleCommunityNoindex.js
-
curl -L -o toggleCommunityNoindex.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/mutations/community/toggleCommunityNoindex.js
820 Bytes
| // @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); | |
| }); | |