Skip to content

Commit

Permalink
Merge branch 'main' into j-s/court-session-type-arraignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 17, 2024
2 parents db5a5c2 + 7e8c82f commit 529d562
Show file tree
Hide file tree
Showing 289 changed files with 5,799 additions and 2,730 deletions.
779 changes: 393 additions & 386 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions apps/download-service/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
WorkMachinesClientConfig,
WorkMachinesClientModule,
} from '@island.is/clients/work-machines'
import { HealthPaymentsOverviewController } from './modules/health/payment-overview-documents.controller'
import {
RightsPortalClientConfig,
RightsPortalClientModule,
Expand All @@ -70,7 +69,6 @@ import {
RegulationDocumentsController,
WorkMachinesController,
OccupationalLicensesController,
HealthPaymentsOverviewController,
],
imports: [
AuditModule.forRoot(environment.audit),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@ export class BackendService extends DataSource<{ req: Request }> {
)
}

limitedAccessUpdateDefendant(
caseId: string,
defendantId: string,
updateDefendant: unknown,
): Promise<Defendant> {
return this.patch(
`case/${caseId}/limitedAccess/defendant/${defendantId}`,
updateDefendant,
)
}

deleteDefendant(
caseId: string,
defendantId: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import { Module } from '@nestjs/common'

import { CivilClaimantResolver } from './civilClaimant.resolver'
import { DefendantResolver } from './defendant.resolver'
import { LimitedAccessDefendantResolver } from './limitedAccessDefendant.resolver'

@Module({
providers: [DefendantResolver, CivilClaimantResolver],
providers: [
DefendantResolver,
CivilClaimantResolver,
LimitedAccessDefendantResolver,
],
})
export class DefendantModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DefendantPlea,
DefenderChoice,
Gender,
PunishmentType,
ServiceRequirement,
SubpoenaType,
} from '@island.is/judicial-system/types'
Expand Down Expand Up @@ -114,4 +115,9 @@ export class UpdateDefendantInput {
@IsOptional()
@Field(() => Boolean, { nullable: true })
readonly isSentToPrisonAdmin?: boolean

@Allow()
@IsOptional()
@Field(() => PunishmentType, { nullable: true })
readonly punishmentType?: PunishmentType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Inject, UseGuards } from '@nestjs/common'
import { Args, Context, Mutation, Resolver } from '@nestjs/graphql'

import type { Logger } from '@island.is/logging'
import { LOGGER_PROVIDER } from '@island.is/logging'

import {
AuditedAction,
AuditTrailService,
} from '@island.is/judicial-system/audit-trail'
import {
CurrentGraphQlUser,
JwtGraphQlAuthGuard,
} from '@island.is/judicial-system/auth'
import type { User } from '@island.is/judicial-system/types'

import { BackendService } from '../backend'
import { UpdateDefendantInput } from './dto/updateDefendant.input'
import { Defendant } from './models/defendant.model'

@UseGuards(JwtGraphQlAuthGuard)
@Resolver()
export class LimitedAccessDefendantResolver {
constructor(
private readonly auditTrailService: AuditTrailService,
@Inject(LOGGER_PROVIDER)
private readonly logger: Logger,
) {}

@Mutation(() => Defendant, { nullable: true })
limitedAccessUpdateDefendant(
@Args('input', { type: () => UpdateDefendantInput })
input: UpdateDefendantInput,
@CurrentGraphQlUser() user: User,
@Context('dataSources')
{ backendService }: { backendService: BackendService },
): Promise<Defendant> {
const { caseId, defendantId, ...updateDefendant } = input
this.logger.debug(
`Updating limitedAccess defendant ${defendantId} for case ${caseId}`,
)

return this.auditTrailService.audit(
user.id,
AuditedAction.UPDATE_DEFENDANT,
backendService.limitedAccessUpdateDefendant(
caseId,
defendantId,
updateDefendant,
),
defendantId,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DefendantPlea,
DefenderChoice,
Gender,
PunishmentType,
ServiceRequirement,
SubpoenaType,
} from '@island.is/judicial-system/types'
Expand All @@ -15,6 +16,7 @@ registerEnumType(DefendantPlea, { name: 'DefendantPlea' })
registerEnumType(ServiceRequirement, { name: 'ServiceRequirement' })
registerEnumType(DefenderChoice, { name: 'DefenderChoice' })
registerEnumType(SubpoenaType, { name: 'SubpoenaType' })
registerEnumType(PunishmentType, { name: 'PunishmentType' })

@ObjectType()
export class Defendant {
Expand Down Expand Up @@ -107,4 +109,7 @@ export class Defendant {

@Field(() => String, { nullable: true })
readonly sentToPrisonAdminDate?: string

@Field(() => PunishmentType, { nullable: true })
readonly punishmentType?: PunishmentType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'

module.exports = {
async up(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction((t) =>
Promise.all([
queryInterface.addColumn(
'defendant',
'punishment_type',
{
type: Sequelize.STRING,
allowNull: true,
},
{ transaction: t },
),
]),
)
},
async down(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction((t) =>
queryInterface.removeColumn('defendant', 'punishment_type', {
transaction: t,
}),
)
},
}
15 changes: 15 additions & 0 deletions apps/judicial-system/backend/src/app/messages/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,4 +856,19 @@ export const notifications = {
description: 'Texti í pósti til aðila máls þegar ný gögn eru send',
},
}),
courtOfficialAssignedEmail: defineMessages({
subject: {
id: 'judicial.system.backend:notifications.court_official_assigned_email.subject',
defaultMessage: 'Úthlutun máls {courtCaseNumber}',
description:
'Fyrirsögn í pósti til dómara og dómritara þegar máli er úthlutað á þau',
},
body: {
id: 'judicial.system.backend:notifications.court_official_assigned_email.body',
defaultMessage:
'Héraðsdómur hefur skráð þig sem {role, select, DISTRICT_COURT_JUDGE {dómara} DISTRICT_COURT_REGISTRAR {dómritara} other {óþekkt}} í máli {courtCaseNumber}. Hægt er að nálgast gögn málsins á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}',
description:
'Texti í pósti til dómara og dómritara þegar máli er úthlutað á þau',
},
}),
}
73 changes: 73 additions & 0 deletions apps/judicial-system/backend/src/app/modules/case/case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
eventTypes,
isCompletedCase,
isIndictmentCase,
isInvestigationCase,
isRequestCase,
isTrafficViolationCase,
notificationTypes,
Expand Down Expand Up @@ -686,6 +687,34 @@ export class CaseService {
])
}

private addMessagesForDistrictCourtJudgeAssignedToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
return this.messageService.sendMessagesToQueue([
{
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: CaseNotificationType.DISTRICT_COURT_JUDGE_ASSIGNED },
},
])
}

private addMessagesForDistrictCourtRegistrarAssignedToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
return this.messageService.sendMessagesToQueue([
{
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: CaseNotificationType.DISTRICT_COURT_REGISTRAR_ASSIGNED },
},
])
}

private addMessagesForReceivedCaseToQueue(
theCase: Case,
user: TUser,
Expand Down Expand Up @@ -845,7 +874,25 @@ export class CaseService {
this.getDeliverProsecutorToCourtMessages(theCase, user),
)
}
private addMessagesForSignedCourtRecordToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
const messages = []

if (
theCase.origin === CaseOrigin.LOKE &&
isInvestigationCase(theCase.type)
) {
messages.push({
type: MessageType.DELIVERY_TO_POLICE_SIGNED_COURT_RECORD,
user,
caseId: theCase.id,
})
}

return this.messageService.sendMessagesToQueue(messages)
}
private addMessagesForSignedRulingToQueue(
theCase: Case,
user: TUser,
Expand Down Expand Up @@ -1384,6 +1431,30 @@ export class CaseService {
}
}

if (
isIndictment &&
[CaseState.SUBMITTED, CaseState.RECEIVED].includes(updatedCase.state)
) {
const isJudgeChanged =
updatedCase.judge?.nationalId !== theCase.judge?.nationalId
const isRegistrarChanged =
updatedCase.registrar?.nationalId !== theCase.registrar?.nationalId

if (isJudgeChanged) {
await this.addMessagesForDistrictCourtJudgeAssignedToQueue(
updatedCase,
user,
)
}

if (isRegistrarChanged) {
await this.addMessagesForDistrictCourtRegistrarAssignedToQueue(
updatedCase,
user,
)
}
}

if (
isIndictment &&
![
Expand Down Expand Up @@ -1899,6 +1970,8 @@ export class CaseService {
false,
)

await this.addMessagesForSignedCourtRecordToQueue(theCase, user)

return { documentSigned: true }
} catch (error) {
this.eventService.postErrorEvent(
Expand Down
Loading

0 comments on commit 529d562

Please sign in to comment.