File size: 478 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// @flow
import type { GraphQLContext } from '../../';
import { canViewDMThread } from '../../utils/permissions';

export default async (
  _: any,
  { id }: { id: string },
  { user, loaders }: GraphQLContext
) => {
  // signed out users should never be able to request a dm thread
  if (!user || !user.id) return null;

  const canViewThread = await canViewDMThread(user.id, id, loaders);

  if (!canViewThread) return null;

  return loaders.directMessageThread.load(id);
};