Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/aosh-accidents-fi…
Browse files Browse the repository at this point in the history
…xes-2
  • Loading branch information
Ballioli committed Jan 8, 2025
2 parents 3d96623 + e0cf15e commit 7545c76
Show file tree
Hide file tree
Showing 247 changed files with 4,258 additions and 2,057 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ codemagic.yaml
/apps/services/regulations-admin-backend/ @island-is/hugsmidjan
/apps/services/user-profile/ @island-is/hugsmidjan @island-is/juni @island-is/aranja
/apps/web/components/Grant/ @island-is/hugsmidjan
/apps/web/components/GrantCardsList/ @island-is/hugsmidjan
/apps/web/screens/Grants/ @island-is/hugsmidjan
/apps/web/screens/Regulations/ @island-is/hugsmidjan
/apps/web/components/Regulations/ @island-is/hugsmidjan
Expand Down
46 changes: 40 additions & 6 deletions apps/contentful-apps/pages/sidebars/preview-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EntryProps, KeyValueMap } from 'contentful-management'
import { CMAClient, SidebarExtensionSDK } from '@contentful/app-sdk'
import { Button, Text } from '@contentful/f36-components'
import { useCMA, useSDK } from '@contentful/react-apps-toolkit'

import {
CONTENTFUL_ENVIRONMENT,
CONTENTFUL_SPACE,
Expand Down Expand Up @@ -40,12 +41,30 @@ const previewLinkHandler = {
) => {
const organizationPageId =
entry.fields.organizationPage?.[DEFAULT_LOCALE]?.sys?.id
const organizationPage = await cma.entry.get({
entryId: organizationPageId,
environmentId: CONTENTFUL_ENVIRONMENT,
spaceId: CONTENTFUL_SPACE,
})
return `${DEV_WEB_BASE_URL}/s/${organizationPage?.fields?.slug?.[DEFAULT_LOCALE]}/${entry.fields.slug[DEFAULT_LOCALE]}`
const [organizationPage, organizationParentSubpageResponse] =
await Promise.all([
cma.entry.get({
entryId: organizationPageId,
environmentId: CONTENTFUL_ENVIRONMENT,
spaceId: CONTENTFUL_SPACE,
}),
cma.entry.getMany({
query: {
content_type: 'organizationParentSubpage',
include: 1,
links_to_entry: entry.sys.id,
'sys.archivedAt[exists]': false,
},
}),
])

const orgPageSlug = organizationPage?.fields?.slug?.[DEFAULT_LOCALE]
const slug = entry.fields.slug[DEFAULT_LOCALE]

if (!organizationParentSubpageResponse?.items?.length) {
return `${DEV_WEB_BASE_URL}/s/${orgPageSlug}/${slug}`
}
return `${DEV_WEB_BASE_URL}/s/${orgPageSlug}/${organizationParentSubpageResponse.items[0].fields.slug[DEFAULT_LOCALE]}/${slug}`
},
anchorPage: (entry: EntryProps<KeyValueMap>) => {
const middlePart =
Expand All @@ -64,6 +83,21 @@ const previewLinkHandler = {
manual: (entry: EntryProps<KeyValueMap>) => {
return `${DEV_WEB_BASE_URL}/handbaekur/${entry.fields.slug[DEFAULT_LOCALE]}`
},
organizationParentSubpage: async (
entry: EntryProps<KeyValueMap>,
cma: CMAClient,
) => {
const organizationPageId =
entry.fields.organizationPage?.[DEFAULT_LOCALE]?.sys?.id
const organizationPage = await cma.entry.get({
entryId: organizationPageId,
environmentId: CONTENTFUL_ENVIRONMENT,
spaceId: CONTENTFUL_SPACE,
})
const orgPageSlug = organizationPage?.fields?.slug?.[DEFAULT_LOCALE]

return `${DEV_WEB_BASE_URL}/s/${orgPageSlug}/${entry.fields.slug[DEFAULT_LOCALE]}`
},
}

const PreviewLinkSidebar = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { ApiScope } from '@island.is/auth/scopes'
import { FinanceClientService } from '@island.is/clients/finance'
import { AuditService } from '@island.is/nest/audit'
import {
Body,
Controller,
Header,
Param,
Post,
Res,
UseGuards,
Query,
} from '@nestjs/common'
import { ApiOkResponse } from '@nestjs/swagger'
import { Response } from 'express'
Expand All @@ -39,19 +39,20 @@ export class FinanceDocumentController {
@CurrentUser() user: User,
@Res() res: Response,
@Param('pdfId') pdfId: string,
@Body('annualDoc') annualDoc?: string,
@Query('action') action?: string,
) {
const documentResponse = annualDoc
? await this.financeService.getAnnualStatusDocument(
user.nationalId,
pdfId,
user,
)
: await this.financeService.getFinanceDocument(
user.nationalId,
pdfId,
user,
)
const documentResponse =
action === 'annualDoc'
? await this.financeService.getAnnualStatusDocument(
user.nationalId,
pdfId,
user,
)
: await this.financeService.getFinanceDocument(
user.nationalId,
pdfId,
user,
)

const documentBase64 = documentResponse?.docment?.document

Expand Down
2 changes: 2 additions & 0 deletions apps/judicial-system/backend/infra/judicial-system-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export const serviceSetup = (): ServiceBuilder<'judicial-system-backend'> =>
PRISON_ADMIN_EMAIL: '/k8s/judicial-system/PRISON_ADMIN_EMAIL',
PRISON_ADMIN_INDICTMENT_EMAILS:
'/k8s/judicial-system/PRISON_ADMIN_INDICTMENT_EMAILS',
PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL:
'/k8s/judicial-system/PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL',
AUTH_JWT_SECRET: '/k8s/judicial-system/AUTH_JWT_SECRET',
ADMIN_USERS: '/k8s/judicial-system/ADMIN_USERS',
BACKEND_ACCESS_TOKEN: '/k8s/judicial-system/BACKEND_ACCESS_TOKEN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
capitalize,
formatDate,
formatDOB,
formatGender,
lowercase,
} from '@island.is/judicial-system/formatters'
import { SessionArrangements } from '@island.is/judicial-system/types'
Expand Down Expand Up @@ -80,14 +81,25 @@ const constructCustodyNoticePdf = (
)
}

addNormalText(doc, 'Lögheimili/dvalarstaður: ', 'Helvetica', true)
addNormalText(
doc,
theCase.defendants &&
theCase.defendants.length > 0 &&
theCase.defendants[0].address
? theCase.defendants[0].address
: 'Heimili ekki skráð',
: 'Ekki skráð',
)
addNormalText(doc, 'Kyn: ', 'Helvetica', true)
addNormalText(
doc,
theCase.defendants &&
theCase.defendants.length > 0 &&
theCase.defendants[0].gender
? formatGender(theCase.defendants[0].gender)
: 'Ekki skráð',
)

addEmptyLines(doc, 2)
setLineGap(doc, 8)
addMediumText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ export const notifications = {
defaultMessage: 'Landsréttur',
description: 'Nafn á Landsrétti í tölvupóstum',
},
publicProsecutorCriminalRecords: {
id: 'judicial.system.backend:notifications.email_names.public_prosecutor_criminal_records',
defaultMessage: 'Ritari sakaskrár',
description: 'Nafn á ritara sakaskrá í tölvupóstum',
},
}),
COAJudgeAssigned: defineMessages({
subject: {
Expand Down Expand Up @@ -837,9 +842,9 @@ export const notifications = {
description: 'Fyrirsögn í pósti til dómstóls þegar ákæra er afturkölluð',
},
body: {
id: 'judicial.system.backend:notifications.court_revoked_indictment_email.body',
id: 'judicial.system.backend:notifications.court_revoked_indictment_email.body_v1',
defaultMessage:
'{prosecutorsOffice} hefur afturkallað ákæru {courtCaseNumber, select, NONE {í máli sem ekki hefur enn fengið málsnúmer} other {í máli {courtCaseNumber}}}.',
'{prosecutorsOffice} hefur afturkallað ákæru í máli {caseNumber}.',
description: 'Texti í pósti til dómstóls þegar ákæra er afturkölluð',
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const custodyNotice = {
defaultMessage:
'Úrskuður um {caseType, select, ADMISSION_TO_FACILITY {vistun á viðeigandi stofnun} other {gæsluvarðhald}}',
description:
'Titill á vistunarselði sem tilgreinir í hverning máli úrskurðurinn er',
'Titill á vistunarseðli sem tilgreinir í hvernig máli úrskurðurinn er',
}),
arrangement: defineMessage({
id: 'judicial.system.backend:pdf.custody_notice.arrangement',
Expand Down
44 changes: 41 additions & 3 deletions apps/judicial-system/backend/src/app/modules/case/case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ export const caseListInclude: Includeable[] = [
order: [['created', 'DESC']],
separate: true,
},
{
model: Subpoena,
as: 'subpoenas',
required: false,
order: [['created', 'DESC']],
separate: true,
},
],
separate: true,
},
Expand Down Expand Up @@ -860,6 +867,17 @@ export class CaseService {
type: MessageType.DELIVERY_TO_COURT_INDICTMENT_CANCELLATION_NOTICE,
user,
caseId: theCase.id,
// Upon case cancellation, we send the same notification type to:
// (1) relevant court emails
// (2) court system (via robot).
//
// When a case is revoked without a court case number, we send email (1).
// The court must then add the case number in the system, triggering notification (2) for full cancellation.
//
// The court system requires a case number before posting data via robot, so it must be added despite the cancellation.
// Notifications (1) and (2) must match, thus we use the flag below to ensure the same message is sent.
// Without the flag, email (2) would get notification including the court case number.
// For more context: https://github.com/island-is/island.is/pull/17385/files#r1904268032
body: { withCourtCaseNumber: false },
})
}
Expand Down Expand Up @@ -1062,7 +1080,7 @@ export class CaseService {
)
}

private addMessagesForRevokedIndictmentCaseToQueue(
private async addMessagesForRevokedIndictmentCaseToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
Expand All @@ -1077,6 +1095,21 @@ export class CaseService {
})
}

const subpoenasToRevoke = await this.subpoenaService.findByCaseId(
theCase.id,
)

if (subpoenasToRevoke?.length > 0) {
messages.push(
...subpoenasToRevoke.map((subpoena) => ({
type: MessageType.DELIVERY_TO_POLICE_SUBPOENA_REVOCATION,
user,
caseId: theCase.id,
elementId: [subpoena.defendantId, subpoena.id],
})),
)
}

return this.messageService.sendMessagesToQueue(messages)
}

Expand Down Expand Up @@ -1460,9 +1493,14 @@ export class CaseService {
[CaseState.SUBMITTED, CaseState.RECEIVED].includes(updatedCase.state)
) {
const isJudgeChanged =
updatedCase.judge?.nationalId !== theCase.judge?.nationalId
updatedCase.judge &&
updatedCase.judge.email &&
updatedCase.judge.nationalId !== theCase.judge?.nationalId

const isRegistrarChanged =
updatedCase.registrar?.nationalId !== theCase.registrar?.nationalId
updatedCase.registrar &&
updatedCase.registrar.email &&
updatedCase.registrar.nationalId !== theCase.registrar?.nationalId

if (isJudgeChanged) {
await this.addMessagesForDistrictCourtJudgeAssignedToQueue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ const prosecutorFields: (keyof UpdateCaseDto)[] = [
'hasCivilClaims',
]

const publicProsecutorFields: (keyof UpdateCaseDto)[] = ['indictmentReviewerId']
const publicProsecutorFields: (keyof UpdateCaseDto)[] = [
'indictmentReviewerId',
'indictmentReviewDecision',
]

const districtCourtFields: (keyof UpdateCaseDto)[] = [
'defenderName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,23 +672,24 @@ export class InternalCaseService {
): Promise<DeliverResponse> {
await this.refreshFormatMessage()

const courtCaseNumber = withCourtCaseNumber && theCase.courtCaseNumber
const caseNumber = courtCaseNumber || theCase.policeCaseNumbers.join(', ')

return this.courtService
.updateIndictmentCaseWithCancellationNotice(
user,
theCase.id,
theCase.court?.name,
theCase.courtCaseNumber,
this.formatMessage(notifications.courtRevokedIndictmentEmail.subject, {
courtCaseNumber:
(withCourtCaseNumber && theCase.courtCaseNumber) || 'NONE',
courtCaseNumber: courtCaseNumber || 'NONE',
}),
stripHtmlTags(
`${this.formatMessage(
notifications.courtRevokedIndictmentEmail.body,
{
prosecutorsOffice: theCase.creatingProsecutor?.institution?.name,
courtCaseNumber:
(withCourtCaseNumber && theCase.courtCaseNumber) || 'NONE',
caseNumber,
},
)} ${this.formatMessage(notifications.emailTail)}`,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class LimitedAccessCaseController {
private readonly limitedAccessCaseService: LimitedAccessCaseService,
private readonly eventService: EventService,
private readonly pdfService: PdfService,
private readonly defendantService: DefendantService,
@Inject(LOGGER_PROVIDER) private readonly logger: Logger,
) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ export const include: Includeable[] = [
},
separate: true,
},
{ model: Institution, as: 'court' },
{ model: User, as: 'judge' },
{ model: Institution, as: 'prosecutorsOffice' },
],
separate: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ describe('InternalCaseController - Deliver indictment cancellation notice to cou
const courtName = uuid()
const courtCaseNumber = uuid()
const prosecutorsOffice = uuid()
const policeCase1 = '007-2022-01'
const policeCase2 = '007-2022-02'

const policeCaseNumbers = [policeCase1, policeCase2]

const theCase = {
id: caseId,
type: CaseType.INDICTMENT,
creatingProsecutor: { institution: { name: prosecutorsOffice } },
court: { name: courtName },
courtCaseNumber,
policeCaseNumbers,
} as Case

let mockCourtService: CourtService
Expand Down Expand Up @@ -88,7 +93,7 @@ describe('InternalCaseController - Deliver indictment cancellation notice to cou
})
})

describe('deliver cancellation notice without court case number', () => {
describe('deliver cancellation notice with police case numbers', () => {
let then: Then

beforeAll(async () => {
Expand All @@ -104,7 +109,7 @@ describe('InternalCaseController - Deliver indictment cancellation notice to cou
courtName,
courtCaseNumber,
'Ákæra afturkölluð',
`${prosecutorsOffice} hefur afturkallað ákæru í máli sem ekki hefur enn fengið málsnúmer. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
`${prosecutorsOffice} hefur afturkallað ákæru í máli ${policeCase1}, ${policeCase2}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
)

expect(then.result).toEqual({ delivered: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const notificationModuleConfig = defineConfig({
'PRISON_ADMIN_INDICTMENT_EMAILS',
'',
),
publicProsecutorCriminalRecordsEmail: env.required(
'PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL',
'',
),
courtsEmails: env.requiredJSON('COURTS_EMAILS', {}) as {
[key: string]: string
},
Expand Down
Loading

0 comments on commit 7545c76

Please sign in to comment.