chore: combine context
This commit is contained in:
@@ -75,10 +75,7 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (_query, _parent, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
resolve: async (_query, _parent, args, _ctx: SchemaContext) => {
|
||||
const collaborationSession = await this.prisma.collaborationSession.findUnique({
|
||||
where: {
|
||||
scheduleDateId: args.scheduleDateId,
|
||||
@@ -112,10 +109,7 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (_, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
if (!ctx.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
const meetingRoom = await this.prisma.meetingRoom.findUnique({
|
||||
@@ -131,11 +125,11 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
if (!collaborationSession) {
|
||||
throw new Error('Collaboration session not found')
|
||||
}
|
||||
if (!collaborationSession.collaboratorsIds.includes(ctx.http.me.id)) {
|
||||
if (!collaborationSession.collaboratorsIds.includes(ctx.me.id)) {
|
||||
throw new Error('User is not collaborator')
|
||||
}
|
||||
// create new token
|
||||
const token = await this.livekitService.createToken(ctx.http.me, meetingRoom.id)
|
||||
const token = await this.livekitService.createToken(ctx.me, meetingRoom.id)
|
||||
return {
|
||||
id: meetingRoom.id,
|
||||
token,
|
||||
@@ -151,13 +145,10 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (_, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
if (!ctx.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
const token = await this.livekitService.createToken(ctx.http.me, args.scheduleId)
|
||||
const token = await this.livekitService.createToken(ctx.me, args.scheduleId)
|
||||
return {
|
||||
id: args.scheduleId,
|
||||
token,
|
||||
@@ -181,10 +172,7 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (query, _parent, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
if (!ctx.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
return await this.prisma.meetingRoom.create({
|
||||
@@ -207,10 +195,7 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (query, _parent, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
if (!ctx.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
return await this.prisma.meetingRoom.update({
|
||||
|
||||
Reference in New Issue
Block a user