Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(j-s): Undefined Slack Events #15831

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class CaseController {

const createdCase = await this.caseService.create(caseToCreate, user)

this.eventService.postEvent(CaseEvent.CREATE, createdCase as Case)
this.eventService.postEvent('CREATE', createdCase)

return createdCase
}
Expand Down Expand Up @@ -419,10 +419,7 @@ export class CaseController {
)

// No need to wait
this.eventService.postEvent(
transition.transition as unknown as CaseEvent,
updatedCase ?? theCase,
)
this.eventService.postEvent(transition.transition, updatedCase ?? theCase)

return updatedCase ?? theCase
}
Expand Down Expand Up @@ -891,7 +888,7 @@ export class CaseController {

const extendedCase = await this.caseService.extend(theCase, user)

this.eventService.postEvent(CaseEvent.EXTEND, extendedCase as Case)
this.eventService.postEvent('EXTEND', extendedCase as Case)

return extendedCase
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ export class CaseService {
await this.addMessagesForUpdatedCaseToQueue(theCase, updatedCase, user)

if (receivingCase) {
this.eventService.postEvent(CaseEvent.RECEIVE, updatedCase)
this.eventService.postEvent(CaseTransition.RECEIVE, updatedCase)
}

if (returnUpdatedCase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class InternalCaseController {

const createdCase = await this.internalCaseService.create(caseToCreate)

this.eventService.postEvent(CaseEvent.CREATE_XRD, createdCase as Case)
this.eventService.postEvent('CREATE_XRD', createdCase as Case)

return createdCase
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export class InternalCaseService {
)
})

this.eventService.postEvent(CaseEvent.ARCHIVE, theCase)
this.eventService.postEvent('ARCHIVE', theCase)

return { caseArchived: true }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ export class LimitedAccessCaseController {
user,
)

this.eventService.postEvent(
transition.transition as unknown as CaseEvent,
updatedCase,
)
this.eventService.postEvent(transition.transition, updatedCase)

return updatedCase
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
formatDate,
readableIndictmentSubtypes,
} from '@island.is/judicial-system/formatters'
import { isIndictmentCase } from '@island.is/judicial-system/types'
import {
CaseTransition,
isIndictmentCase,
} from '@island.is/judicial-system/types'

import { type Case } from '../case'
import { DateLog } from '../case/models/dateLog.model'
Expand All @@ -37,50 +40,42 @@ const errorEmojis = [
':x:',
]

const caseEvent = {
const caseEvent: Record<CaseEvent, string> = {
[CaseTransition.ACCEPT]: ':white_check_mark: Samþykkt',
[CaseTransition.APPEAL]: ':judge: Kæra',
ARCHIVE: ':file_cabinet: Sett í geymslu',
[CaseTransition.ASK_FOR_CANCELLATION]: ':interrobang: Beðið um aftuköllun',
[CaseTransition.ASK_FOR_CONFIRMATION]: ':question: Beðið um staðfestingu',
[CaseTransition.COMPLETE]: ':white_check_mark: Lokið',
[CaseTransition.COMPLETE_APPEAL]: ':white_check_mark: Kæru lokið',
[CaseTransition.DELETE]: ':fire: Afturkallað',
[CaseTransition.DENY_INDICTMENT]: ':no_entry_sign: Ákæru hafnað',
[CaseTransition.DISMISS]: ':woman-shrugging: Vísað frá',
CREATE: ':new: Mál stofnað',
CREATE_XRD: ':new: Mál stofnað í gegnum Strauminn',
EXTEND: ':recycle: Mál framlengt',
OPEN: ':unlock: Opnað fyrir dómstól',
ASK_FOR_CONFIRMATION: ':question: Beðið um staðfestingu',
SUBMIT: ':mailbox_with_mail: Sent',
[CaseTransition.OPEN]: ':unlock: Opnað fyrir dómstól',
[CaseTransition.RECEIVE]: ':eyes: Móttekið',
[CaseTransition.RECEIVE_APPEAL]: ':eyes: Kæra móttekin',
[CaseTransition.REJECT]: ':negative_squared_cross_mark: Hafnað',
[CaseTransition.REOPEN]: ':construction: Opnað aftur',
[CaseTransition.REOPEN_APPEAL]: ':building_construction: Kæra opnuð aftur',
RESUBMIT: ':mailbox_with_mail: Sent aftur',
RECEIVE: ':eyes: Móttekið',
ACCEPT: ':white_check_mark: Samþykkt',
REJECT: ':negative_squared_cross_mark: Hafnað',
DISMISS: ':woman-shrugging: Vísað frá',
COMPLETE: ':white_check_mark: Lokið',
DELETE: ':fire: Afturkallað',
[CaseTransition.RETURN_INDICTMENT]: ':woman-gesturing-no: Ákæru afturkallað',
SCHEDULE_COURT_DATE: ':timer_clock: Fyrirtökutíma úthlutað',
ARCHIVE: ':file_cabinet: Sett í geymslu',
REOPEN: ':construction: Opnað aftur',
APPEAL: ':judge: Kæra',
RECEIVE_APPEAL: ':eyes: Kæra móttekin',
COMPLETE_APPEAL: ':white_check_mark: Kæru lokið',
REOPEN_APPEAL: ':building_construction: Kæra opnuð aftur',
[CaseTransition.SUBMIT]: ':mailbox_with_mail: Sent',
[CaseTransition.WITHDRAW_APPEAL]:
':leftwards_arrow_with_hook: Kæru afturkallað',
gudjong marked this conversation as resolved.
Show resolved Hide resolved
gudjong marked this conversation as resolved.
Show resolved Hide resolved
}

export enum CaseEvent {
CREATE = 'CREATE',
CREATE_XRD = 'CREATE_XRD',
EXTEND = 'EXTEND',
OPEN = 'OPEN',
ASK_FOR_CONFIRMATION = 'ASK_FOR_CONFIRMATION',
SUBMIT = 'SUBMIT',
RESUBMIT = 'RESUBMIT',
RECEIVE = 'RECEIVE',
ACCEPT = 'ACCEPT',
REJECT = 'REJECT',
DELETE = 'DELETE',
SCHEDULE_COURT_DATE = 'SCHEDULE_COURT_DATE',
DISMISS = 'DISMISS',
ARCHIVE = 'ARCHIVE',
REOPEN = 'REOPEN',
APPEAL = 'APPEAL',
RECEIVE_APPEAL = 'RECEIVE_APPEAL',
COMPLETE_APPEAL = 'COMPLETE_APPEAL',
REOPEN_APPEAL = 'REOPEN_APPEAL',
}
export type CaseEvent =
| CaseTransition
gudjong marked this conversation as resolved.
Show resolved Hide resolved
| 'ARCHIVE'
| 'CREATE'
| 'CREATE_XRD'
| 'EXTEND'
| 'RESUBMIT'
| 'SCHEDULE_COURT_DATE'
gudjong marked this conversation as resolved.
Show resolved Hide resolved

@Injectable()
export class EventService {
Expand Down Expand Up @@ -120,7 +115,7 @@ export class EventService {
? `\n>Landsréttur *${theCase.appealCaseNumber}*`
: ''
const extraText =
event === CaseEvent.SCHEDULE_COURT_DATE
event === 'SCHEDULE_COURT_DATE'
? `\n>Dómari ${
theCase.judge?.name ?? 'er ekki skráður'
}\n>Dómritari ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class InternalNotificationService extends BaseNotificationService {
} else if (theCase.state === CaseState.RECEIVED) {
promises.push(this.sendResubmittedToCourtSmsNotificationToCourt(theCase))

this.eventService.postEvent(CaseEvent.RESUBMIT, theCase)
this.eventService.postEvent('RESUBMIT', theCase)
gudjong marked this conversation as resolved.
Show resolved Hide resolved
}

if (
Expand Down Expand Up @@ -768,7 +768,7 @@ export class InternalNotificationService extends BaseNotificationService {
theCase: Case,
user: User,
): Promise<DeliverResponse> {
this.eventService.postEvent(CaseEvent.SCHEDULE_COURT_DATE, theCase)
this.eventService.postEvent('SCHEDULE_COURT_DATE', theCase)
gudjong marked this conversation as resolved.
Show resolved Hide resolved

const promises: Promise<Recipient>[] = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ export class NotificationService {
break
case NotificationType.COURT_DATE:
if (eventOnly) {
this.eventService.postEvent(
CaseEvent.SCHEDULE_COURT_DATE,
theCase,
true,
)
this.eventService.postEvent('SCHEDULE_COURT_DATE', theCase, true)

// We still want to send the defender a link to the case even if
// the judge chooses not to send a calendar invitation
Expand Down
44 changes: 22 additions & 22 deletions libs/judicial-system/types/src/lib/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,50 +132,50 @@ export enum CaseAppealState {
}

export enum CaseTransition {
OPEN = 'OPEN',
ACCEPT = 'ACCEPT',
APPEAL = 'APPEAL',
ASK_FOR_CANCELLATION = 'ASK_FOR_CANCELLATION',
ASK_FOR_CONFIRMATION = 'ASK_FOR_CONFIRMATION',
COMPLETE = 'COMPLETE',
COMPLETE_APPEAL = 'COMPLETE_APPEAL',
DELETE = 'DELETE',
DENY_INDICTMENT = 'DENY_INDICTMENT',
SUBMIT = 'SUBMIT',
ASK_FOR_CANCELLATION = 'ASK_FOR_CANCELLATION',
DISMISS = 'DISMISS',
OPEN = 'OPEN',
RECEIVE = 'RECEIVE',
RETURN_INDICTMENT = 'RETURN_INDICTMENT',
COMPLETE = 'COMPLETE',
ACCEPT = 'ACCEPT',
RECEIVE_APPEAL = 'RECEIVE_APPEAL',
REJECT = 'REJECT',
DISMISS = 'DISMISS',
DELETE = 'DELETE',
REOPEN = 'REOPEN',
APPEAL = 'APPEAL',
RECEIVE_APPEAL = 'RECEIVE_APPEAL',
COMPLETE_APPEAL = 'COMPLETE_APPEAL',
REOPEN_APPEAL = 'REOPEN_APPEAL',
RETURN_INDICTMENT = 'RETURN_INDICTMENT',
SUBMIT = 'SUBMIT',
WITHDRAW_APPEAL = 'WITHDRAW_APPEAL',
}

export enum IndictmentCaseTransition {
ASK_FOR_CANCELLATION = CaseTransition.ASK_FOR_CANCELLATION,
ASK_FOR_CONFIRMATION = CaseTransition.ASK_FOR_CONFIRMATION,
COMPLETE = CaseTransition.COMPLETE,
DELETE = CaseTransition.DELETE,
DENY_INDICTMENT = CaseTransition.DENY_INDICTMENT,
SUBMIT = CaseTransition.SUBMIT,
ASK_FOR_CANCELLATION = CaseTransition.ASK_FOR_CANCELLATION,
RECEIVE = CaseTransition.RECEIVE,
RETURN_INDICTMENT = CaseTransition.RETURN_INDICTMENT,
COMPLETE = CaseTransition.COMPLETE,
DELETE = CaseTransition.DELETE,
SUBMIT = CaseTransition.SUBMIT,
}

export enum RequestCaseTransition {
ACCEPT = CaseTransition.ACCEPT,
APPEAL = CaseTransition.APPEAL,
COMPLETE_APPEAL = CaseTransition.COMPLETE_APPEAL,
DELETE = CaseTransition.DELETE,
DISMISS = CaseTransition.DISMISS,
OPEN = CaseTransition.OPEN,
SUBMIT = CaseTransition.SUBMIT,
RECEIVE = CaseTransition.RECEIVE,
ACCEPT = CaseTransition.ACCEPT,
RECEIVE_APPEAL = CaseTransition.RECEIVE_APPEAL,
REJECT = CaseTransition.REJECT,
DISMISS = CaseTransition.DISMISS,
DELETE = CaseTransition.DELETE,
REOPEN = CaseTransition.REOPEN,
APPEAL = CaseTransition.APPEAL,
RECEIVE_APPEAL = CaseTransition.RECEIVE_APPEAL,
COMPLETE_APPEAL = CaseTransition.COMPLETE_APPEAL,
REOPEN_APPEAL = CaseTransition.REOPEN_APPEAL,
SUBMIT = CaseTransition.SUBMIT,
WITHDRAW_APPEAL = CaseTransition.WITHDRAW_APPEAL,
}

Expand Down
Loading