@@ -412,7 +412,17 @@ export async function getAppEditPageHandler(req: Request, res: Response) {
412
412
export async function postDeleteAppChannelHandler ( req : Request , res : Response ) {
413
413
const { aid, cid } = req . params ;
414
414
415
- await db ( 'app_channels' ) . where ( { id : cid } ) . del ( ) ;
415
+ await db ( 'app_channels' )
416
+ . where ( 'app_channels.id' , cid )
417
+ . andWhere ( function ( ) {
418
+ this . whereExists ( function ( ) {
419
+ this . select ( 'apps.id' )
420
+ . from ( 'apps' )
421
+ . where ( 'apps.id' , aid )
422
+ . andWhere ( 'apps.user_id' , req . session ?. user ?. id ) ;
423
+ } ) ;
424
+ } )
425
+ . delete ( ) ;
416
426
417
427
return res . redirect ( `/apps/${ aid } /channels?toast=🗑️ deleted` ) ;
418
428
}
@@ -421,7 +431,17 @@ export async function postDeleteAppChannelHandler(req: Request, res: Response) {
421
431
export async function postDeleteAppNotificationHandler ( req : Request , res : Response ) {
422
432
const { id, nid } = req . params ;
423
433
424
- await db ( 'notifications' ) . where ( { id : nid } ) . del ( ) ;
434
+ await db ( 'notifications' )
435
+ . where ( 'notifications.id' , nid )
436
+ . andWhere ( function ( ) {
437
+ this . whereExists ( function ( ) {
438
+ this . select ( 'apps.id' )
439
+ . from ( 'apps' )
440
+ . where ( 'apps.id' , id )
441
+ . andWhere ( 'apps.user_id' , req . session ?. user ?. id ) ;
442
+ } ) ;
443
+ } )
444
+ . delete ( ) ;
425
445
426
446
req . flash ( 'info' , '🗑️ deleted' ) ;
427
447
0 commit comments