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