Download spectrum/api/queries/channel/community.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 573 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/channel/community.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/channel/community.js
-
curl -L -o community.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/channel/community.js
573 Bytes
| // @flow | |
| import type { GraphQLContext } from '../../'; | |
| import type { DBChannel } from 'shared/types'; | |
| import { canViewCommunity } from '../../utils/permissions'; | |
| export default async (channel: DBChannel, _: any, ctx: GraphQLContext) => { | |
| const { communityId } = channel; | |
| const { loaders, user: currentUser } = ctx; | |
| const community = await loaders.community.load(communityId); | |
| if (community.isPrivate) { | |
| if (await canViewCommunity(currentUser, community.id, loaders)) { | |
| return community; | |
| } else { | |
| return null; | |
| } | |
| } | |
| return community; | |
| }; | |