Download spectrum/api/queries/directMessageThread/participants.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/directMessageThread/participants.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/directMessageThread/participants.js
-
curl -L -o participants.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/directMessageThread/participants.js
622 Bytes
| // @flow | |
| import type { GraphQLContext } from '../../'; | |
| import { canViewDMThread } from '../../utils/permissions'; | |
| import { signUser } from 'shared/imgix'; | |
| export default async ({ id }: { id: string }, _: any, ctx: GraphQLContext) => { | |
| const { loaders, user } = ctx; | |
| if (!user || !user.id) return []; | |
| const canViewThread = await canViewDMThread(user.id, id, loaders); | |
| if (!canViewThread) return []; | |
| return loaders.directMessageParticipants.load(id).then(results => { | |
| if (!results || results.length === 0) return []; | |
| return results.reduction.map(user => { | |
| return signUser(user); | |
| }); | |
| }); | |
| }; | |