1- // @ts -nocheck
2-
31import { ForbiddenException , Injectable , NotFoundException } from '@nestjs/common' ;
42import { PrismaService } from '../database/prisma.service' ;
53import { CreateNoteDto } from './dto/transaction-note.dto' ;
@@ -12,7 +10,7 @@ export class TransactionNotesService {
1210 const tx = await this . prisma . transaction . findUnique ( { where : { id : transactionId } } ) ;
1311 if ( ! tx ) throw new NotFoundException ( 'Transaction not found' ) ;
1412
15- return ( this . prisma as any ) . transactionNote . create ( {
13+ return this . prisma . transactionNote . create ( {
1614 data : {
1715 transactionId,
1816 authorId,
@@ -31,15 +29,12 @@ export class TransactionNotesService {
3129
3230 const where : any = { transactionId } ;
3331 if ( ! isPrivileged && ! isParty ) {
34- // Non-party/non-admin can only see public notes authored by themselves
3532 where . isPublic = true ;
3633 } else if ( ! isPrivileged ) {
37- // Transaction parties see public notes and their own private notes
3834 where . OR = [ { isPublic : true } , { authorId : viewerId } ] ;
3935 }
40- // Admins/agents see all notes
4136
42- return ( this . prisma as any ) . transactionNote . findMany ( {
37+ return this . prisma . transactionNote . findMany ( {
4338 where,
4439 orderBy : { createdAt : 'asc' } ,
4540 include : {
@@ -49,14 +44,14 @@ export class TransactionNotesService {
4944 }
5045
5146 async remove ( noteId : string , requesterId : string , requesterRole : string ) {
52- const note = await ( this . prisma as any ) . transactionNote . findUnique ( { where : { id : noteId } } ) ;
47+ const note = await this . prisma . transactionNote . findUnique ( { where : { id : noteId } } ) ;
5348 if ( ! note ) throw new NotFoundException ( 'Note not found' ) ;
5449
5550 const isPrivileged = requesterRole === 'ADMIN' ;
5651 if ( note . authorId !== requesterId && ! isPrivileged ) {
5752 throw new ForbiddenException ( 'Only the author or admin can delete this note' ) ;
5853 }
5954
60- return ( this . prisma as any ) . transactionNote . delete ( { where : { id : noteId } } ) ;
55+ return this . prisma . transactionNote . delete ( { where : { id : noteId } } ) ;
6156 }
6257}
0 commit comments