ba me thang khoi
This commit is contained in:
@@ -75,6 +75,7 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
'Retrieve a single collaboration session by its unique identifier.',
|
||||
resolve: async (_query, _root, args, ctx, _info) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (!ctx.http.me) throw new Error('Cannot get your info')
|
||||
const scheduleDate = await this.prisma.scheduleDate.findUnique({
|
||||
where: {
|
||||
id: args.scheduleDateId,
|
||||
@@ -96,8 +97,19 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
throw new Error('User not allowed')
|
||||
}
|
||||
/* ---------- use case 2 : center mentor get collaboration session by schedule date id --------- */
|
||||
if (ctx.http.me?.role !== Role.CENTER_MENTOR)
|
||||
throw new Error('Mentor does not created collaboration session yet')
|
||||
if (
|
||||
ctx.http.me.role !== Role.CENTER_MENTOR &&
|
||||
ctx.http.me.role !== Role.CENTER_OWNER
|
||||
) {
|
||||
if (!collaborationSession)
|
||||
throw new Error(
|
||||
'Mentor does not created collaboration session yet',
|
||||
)
|
||||
throw new Error('User not allowed')
|
||||
}
|
||||
// check if user is participant
|
||||
if (!scheduleDate.participantIds.includes(ctx.http.me.id))
|
||||
throw new Error('User not allowed')
|
||||
// check if order is exist in schedule date
|
||||
if (!scheduleDate.orderId) throw new Error('Order not found')
|
||||
const order = await this.prisma.order.findUnique({
|
||||
@@ -131,7 +143,7 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
data: {
|
||||
scheduleDateId: scheduleDate.id,
|
||||
// assign chat room
|
||||
chatRoomId: order.chatRoomId,
|
||||
chatRoomId: chatRoom.id,
|
||||
},
|
||||
})
|
||||
// case after start time and before end time, mark as late
|
||||
|
||||
Reference in New Issue
Block a user