@@ -6,7 +6,6 @@ import { ChatInstance, Enrolment, UserChatInstanceUsage, Prompt, User, Responsib
6
6
import { getOwnCourses } from '../services/chatInstances/access'
7
7
import { encrypt , decrypt } from '../util/util'
8
8
import { ApplicationError } from '../util/ApplicationError'
9
- import { cleanIdStringSchema } from '../util/zodSchemas'
10
9
11
10
const courseRouter = express . Router ( )
12
11
@@ -324,18 +323,6 @@ courseRouter.post('/:id/responsibilities/assign', async (req, res) => {
324
323
}
325
324
const assignedUserUsername : string = body . username
326
325
327
- const chatInstanceIdClean = cleanIdStringSchema . safeParse ( chatInstanceId )
328
- if ( ! chatInstanceIdClean . success ) {
329
- res . status ( 400 ) . send ( 'Malformed chat instance id' )
330
- return
331
- }
332
- //username also must be of similar format as the id only letters and numbers
333
- const assignedUserUsernameClean = cleanIdStringSchema . safeParse ( assignedUserUsername )
334
- if ( ! assignedUserUsernameClean . success ) {
335
- res . status ( 400 ) . send ( 'Malformed assigned user id' )
336
- return
337
- }
338
-
339
326
const request = req as unknown as RequestWithUser
340
327
const { user } = request
341
328
const chatInstance = await getChatInstance ( chatInstanceId )
@@ -352,7 +339,7 @@ courseRouter.post('/:id/responsibilities/assign', async (req, res) => {
352
339
}
353
340
354
341
const assignedUserId = userToAssign . id
355
- const userAssignedAlready = await userAssignedAsResponsible ( assignedUserId , chatInstance )
342
+ const userAssignedAlready = userAssignedAsResponsible ( assignedUserId , chatInstance )
356
343
if ( userAssignedAlready ) {
357
344
res . status ( 400 ) . send ( 'User is already responsible for the course' )
358
345
return
@@ -385,19 +372,6 @@ courseRouter.post('/:id/responsibilities/remove', async (req, res) => {
385
372
}
386
373
const assignedUserUsername : string = body . username
387
374
388
- const chatInstanceIdClean = cleanIdStringSchema . safeParse ( chatInstanceId )
389
- if ( ! chatInstanceIdClean . success ) {
390
- res . status ( 400 ) . send ( 'Malformed chat instance id' )
391
- return
392
- }
393
-
394
- //username also must be of similar format as the id only letters and numbers
395
- const assignedUserUsernameClean = cleanIdStringSchema . safeParse ( assignedUserUsername )
396
- if ( ! assignedUserUsernameClean . success ) {
397
- res . status ( 400 ) . send ( 'Malformed assigned user id' )
398
- return
399
- }
400
-
401
375
const request = req as unknown as RequestWithUser
402
376
const { user } = request
403
377
const chatInstance = await getChatInstance ( chatInstanceId )
@@ -414,7 +388,7 @@ courseRouter.post('/:id/responsibilities/remove', async (req, res) => {
414
388
}
415
389
416
390
const assignedUserId : string = userToRemove . id
417
- const userAssignedAlready : boolean = await userAssignedAsResponsible ( assignedUserId , chatInstance )
391
+ const userAssignedAlready : boolean = userAssignedAsResponsible ( assignedUserId , chatInstance )
418
392
if ( ! userAssignedAlready ) {
419
393
res . status ( 400 ) . send ( 'User to remove not found' )
420
394
return
0 commit comments