Skip to content

Commit

Permalink
fix(j-s): Subpoena Notifications (#16556)
Browse files Browse the repository at this point in the history
* Rewrites subpoena notifications

* Fixes type

* Updates unit tests

* Fixes typo

* Fixes required argument

* Changes error logging

* Update apps/judicial-system/backend/src/app/modules/notification/internalNotification.controller.ts

Fixes typo

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: unakb <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 66f2b3b commit 70a3148
Show file tree
Hide file tree
Showing 72 changed files with 643 additions and 529 deletions.
42 changes: 21 additions & 21 deletions apps/judicial-system/api/src/app/modules/file/file.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,60 +177,60 @@ export class FileController {
)
}

@Get('serviceCertificate/:defendantId/:subpoenaId')
@Get(['subpoena/:defendantId', 'subpoena/:defendantId/:subpoenaId'])
@Header('Content-Type', 'application/pdf')
getServiceCertificatePdf(
getSubpoenaPdf(
@Param('id') id: string,
@Param('defendantId') defendantId: string,
@CurrentHttpUser() user: User,
@Req() req: Request,
@Res() res: Response,
@Param('subpoenaId') subpoenaId?: string,
@Query('arraignmentDate') arraignmentDate?: string,
@Query('location') location?: string,
@Query('subpoenaType') subpoenaType?: SubpoenaType,
): Promise<Response> {
this.logger.debug(
`Getting service certificate for defendant ${defendantId} of case ${id} as a pdf document`,
`Getting subpoena ${
subpoenaId ?? 'draft'
} for defendant ${defendantId} of case ${id} as a pdf document`,
)

const subpoenaIdInjection = subpoenaId ? `/${subpoenaId}` : ''
const queryInjection = arraignmentDate
? `?arraignmentDate=${arraignmentDate}&location=${location}&subpoenaType=${subpoenaType}`
: ''

return this.fileService.tryGetFile(
user.id,
AuditedAction.GET_SERVICE_CERTIFICATE_PDF,
AuditedAction.GET_SUBPOENA_PDF,
id,
`defendant/${defendantId}/subpoena/${subpoenaId}/serviceCertificate`,
`defendant/${defendantId}/subpoena${subpoenaIdInjection}${queryInjection}`,
req,
res,
'pdf',
)
}

@Get('subpoena/:defendantId')
@Get('serviceCertificate/:defendantId/:subpoenaId')
@Header('Content-Type', 'application/pdf')
getSubpoenaPdf(
getServiceCertificatePdf(
@Param('id') id: string,
@Param('defendantId') defendantId: string,
@Param('subpoenaId') subpoenaId: string,
@CurrentHttpUser() user: User,
@Req() req: Request,
@Res() res: Response,
@Param('subpoenaId') subpoenaId?: string,
@Query('arraignmentDate') arraignmentDate?: string,
@Query('location') location?: string,
@Query('subpoenaType') subpoenaType?: SubpoenaType,
): Promise<Response> {
this.logger.debug(
`Getting subpoena ${
subpoenaId ?? 'draft'
} for defendant ${defendantId} of case ${id} as a pdf document`,
`Getting service certificate for subpoena ${subpoenaId} of defendant ${defendantId} and case ${id} as a pdf document`,
)

const subpoenaIdInjection = subpoenaId ? `/${subpoenaId}` : ''
const queryInjection = arraignmentDate
? `?arraignmentDate=${arraignmentDate}&location=${location}&subpoenaType=${subpoenaType}`
: ''

return this.fileService.tryGetFile(
user.id,
AuditedAction.GET_SUBPOENA_PDF,
AuditedAction.GET_SERVICE_CERTIFICATE_PDF,
id,
`defendant/${defendantId}/subpoena${subpoenaIdInjection}${queryInjection}`,
`defendant/${defendantId}/subpoena/${subpoenaId}/serviceCertificate`,
req,
res,
'pdf',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PDFDocument from 'pdfkit'
import { MessageDescriptor } from 'react-intl'
import { MessageDescriptor } from '@formatjs/intl'

import { FormatMessage } from '@island.is/cms-translations'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineMessages } from 'react-intl'
import { defineMessages } from '@formatjs/intl'

export const courtUpload = defineMessages({
request: {
Expand Down
3 changes: 1 addition & 2 deletions apps/judicial-system/backend/src/app/messages/pdfCore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineMessage } from 'react-intl'
import { defineMessages } from '@formatjs/intl'
import { defineMessage, defineMessages } from '@formatjs/intl'

export const core = {
and: defineMessage({
Expand Down
30 changes: 15 additions & 15 deletions apps/judicial-system/backend/src/app/modules/case/case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
CaseFileCategory,
CaseFileState,
CaseIndictmentRulingDecision,
CaseNotificationType,
CaseOrigin,
CaseState,
CaseTransition,
Expand All @@ -43,7 +44,6 @@ import {
isIndictmentCase,
isRequestCase,
isTrafficViolationCase,
NotificationType,
StringType,
UserRole,
} from '@island.is/judicial-system/types'
Expand Down Expand Up @@ -629,7 +629,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.READY_FOR_COURT },
body: { type: CaseNotificationType.READY_FOR_COURT },
},
])
}
Expand All @@ -643,7 +643,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.RECEIVED_BY_COURT },
body: { type: CaseNotificationType.RECEIVED_BY_COURT },
},
]

Expand Down Expand Up @@ -805,7 +805,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.RULING },
body: { type: CaseNotificationType.RULING },
},
]

Expand Down Expand Up @@ -876,7 +876,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.RULING },
body: { type: CaseNotificationType.RULING },
},
]

Expand All @@ -900,7 +900,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.MODIFIED },
body: { type: CaseNotificationType.MODIFIED },
},
]

Expand All @@ -921,7 +921,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.REVOKED },
body: { type: CaseNotificationType.REVOKED },
},
]
}
Expand Down Expand Up @@ -987,7 +987,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_TO_COURT_OF_APPEALS },
body: { type: CaseNotificationType.APPEAL_TO_COURT_OF_APPEALS },
})

return this.messageService.sendMessagesToQueue(messages)
Expand All @@ -1002,7 +1002,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_RECEIVED_BY_COURT },
body: { type: CaseNotificationType.APPEAL_RECEIVED_BY_COURT },
},
])
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_COMPLETED },
body: { type: CaseNotificationType.APPEAL_COMPLETED },
},
{
type: MessageType.DELIVERY_TO_COURT_OF_APPEALS_CONCLUSION,
Expand Down Expand Up @@ -1063,7 +1063,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_STATEMENT },
body: { type: CaseNotificationType.APPEAL_STATEMENT },
},
])
}
Expand All @@ -1077,7 +1077,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_WITHDRAWN },
body: { type: CaseNotificationType.APPEAL_WITHDRAWN },
},
])
}
Expand All @@ -1091,7 +1091,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.INDICTMENT_DENIED },
body: { type: CaseNotificationType.INDICTMENT_DENIED },
},
])
}
Expand All @@ -1105,7 +1105,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.INDICTMENT_RETURNED },
body: { type: CaseNotificationType.INDICTMENT_RETURNED },
},
])
}
Expand Down Expand Up @@ -1168,7 +1168,7 @@ export class CaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.COURT_DATE },
body: { type: CaseNotificationType.COURT_DATE },
},
])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import {
CaseAppealState,
CaseFileCategory,
CaseFileState,
CaseNotificationType,
CaseState,
DateType,
EventType,
NotificationType,
StringType,
UserRole,
} from '@island.is/judicial-system/types'
Expand Down Expand Up @@ -358,7 +358,7 @@ export class LimitedAccessCaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_TO_COURT_OF_APPEALS },
body: { type: CaseNotificationType.APPEAL_TO_COURT_OF_APPEALS },
})
}

Expand All @@ -367,7 +367,7 @@ export class LimitedAccessCaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_WITHDRAWN },
body: { type: CaseNotificationType.APPEAL_WITHDRAWN },
})
}

Expand All @@ -382,7 +382,7 @@ export class LimitedAccessCaseService {
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.APPEAL_STATEMENT },
body: { type: CaseNotificationType.APPEAL_STATEMENT },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { uuid } from 'uuidv4'
import { MessageService, MessageType } from '@island.is/judicial-system/message'
import {
CaseFileState,
CaseNotificationType,
CaseOrigin,
NotificationType,
User,
} from '@island.is/judicial-system/types'

Expand Down Expand Up @@ -136,7 +136,7 @@ describe('CaseController - Get ruling signature confirmation', () => {
type: MessageType.NOTIFICATION,
user,
caseId,
body: { type: NotificationType.RULING },
body: { type: CaseNotificationType.RULING },
},
])
expect(then.result).toEqual({ documentSigned: true })
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('CaseController - Get ruling signature confirmation', () => {
type: MessageType.NOTIFICATION,
user,
caseId,
body: { type: NotificationType.RULING },
body: { type: CaseNotificationType.RULING },
},
{ type: MessageType.DELIVERY_TO_POLICE_SIGNED_RULING, user, caseId },
])
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('CaseController - Get ruling signature confirmation', () => {
type: MessageType.NOTIFICATION,
user,
caseId,
body: { type: NotificationType.RULING },
body: { type: CaseNotificationType.RULING },
},
{ type: MessageType.DELIVERY_TO_POLICE_SIGNED_RULING, user, caseId },
])
Expand Down
Loading

0 comments on commit 70a3148

Please sign in to comment.