Skip to content

Commit

Permalink
fix(j-s): Prison admin indictment notifications (#17097)
Browse files Browse the repository at this point in the history
* fix(j-s): Prison admin indictment notifications

Notifications weren't getting sent due to a bug in the defendant model that returned an undefined value for defendant.caseId

* Update defendant.service.ts

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
unakb and kodiakhq[bot] authored Dec 2, 2024
1 parent 4137b1f commit 6ca2d70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class DefendantService {

private getMessagesForIndictmentToPrisonAdminChanges(
defendant: Defendant,
caseId: string,
): Message {
const messageType =
defendant.isSentToPrisonAdmin === true
Expand All @@ -84,7 +85,7 @@ export class DefendantService {

const message = {
type: MessageType.DEFENDANT_NOTIFICATION,
caseId: defendant.caseId,
caseId,
elementId: defendant.id,
body: {
type: messageType,
Expand Down Expand Up @@ -196,7 +197,10 @@ export class DefendantService {
updatedDefendant.isSentToPrisonAdmin !== oldDefendant.isSentToPrisonAdmin
) {
messages.push(
this.getMessagesForIndictmentToPrisonAdminChanges(updatedDefendant),
this.getMessagesForIndictmentToPrisonAdminChanges(
updatedDefendant,
theCase.id,
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Defendant extends Model {
@ApiProperty({ type: String })
caseId!: string

@BelongsTo(() => Case, 'case_id')
@BelongsTo(() => Case, 'caseId')
@ApiPropertyOptional({ type: () => Case })
case?: Case

Expand Down

0 comments on commit 6ca2d70

Please sign in to comment.