Download spectrum/api/queries/community/watercooler.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 579 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/community/watercooler.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/community/watercooler.js
-
curl -L -o watercooler.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/community/watercooler.js
579 Bytes
| // @flow | |
| import type { GraphQLContext } from '../../'; | |
| import type { DBCommunity } from 'shared/types'; | |
| import { getThreads } from '../../models/thread'; | |
| import { canViewCommunity } from '../../utils/permissions'; | |
| export default async (root: DBCommunity, _: any, ctx: GraphQLContext) => { | |
| const { watercoolerId, id } = root; | |
| const { user, loaders } = ctx; | |
| if (!watercoolerId) return null; | |
| if (!await canViewCommunity(user, id, loaders)) { | |
| return null; | |
| } | |
| return await getThreads([watercoolerId]).then( | |
| res => (res && res.length > 0 ? res[0] : null) | |
| ); | |
| }; | |