Download spectrum/api/mutations/channel/editChannel.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 918 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/mutations/channel/editChannel.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/mutations/channel/editChannel.js
-
curl -L -o editChannel.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/mutations/channel/editChannel.js
918 Bytes
| // @flow | |
| import type { GraphQLContext } from '../../'; | |
| import type { EditChannelInput } from '../../models/channel'; | |
| import UserError from '../../utils/UserError'; | |
| import { approvePendingUsersInChannel } from '../../models/usersChannels'; | |
| import { editChannel } from '../../models/channel'; | |
| import { | |
| isAuthedResolver as requireAuth, | |
| canModerateChannel, | |
| } from '../../utils/permissions'; | |
| export default requireAuth( | |
| async (_: any, args: EditChannelInput, ctx: GraphQLContext) => { | |
| const { user, loaders } = ctx; | |
| const channel = await loaders.channel.load(args.input.channelId); | |
| if (!(await canModerateChannel(user.id, args.input.channelId, loaders))) { | |
| return new UserError('You don’t have permission to manage this channel'); | |
| } | |
| if (channel.isPrivate && !args.input.isPrivate) { | |
| approvePendingUsersInChannel(args.input.channelId); | |
| } | |
| return editChannel(args); | |
| } | |
| ); | |