diff --git a/apps/judicial-system/backend/src/app/modules/notification/dto/subpoenaNotification.dto.ts b/apps/judicial-system/backend/src/app/modules/notification/dto/subpoenaNotification.dto.ts index 14d43cef27f5..e1b0bf519135 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/dto/subpoenaNotification.dto.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/dto/subpoenaNotification.dto.ts @@ -1,9 +1,11 @@ -import { IsEnum, IsNotEmpty, IsUUID } from 'class-validator' +import { IsEnum, IsNotEmpty } from 'class-validator' import { ApiProperty } from '@nestjs/swagger' import { NotificationType } from '@island.is/judicial-system/types' +import { Subpoena } from '../../subpoena' + export class SubpoenaNotificationDto { @IsNotEmpty() @IsEnum(NotificationType) @@ -11,7 +13,6 @@ export class SubpoenaNotificationDto { readonly type!: NotificationType @IsNotEmpty() - @IsUUID() - @ApiProperty({ type: String }) - readonly subpoenaId!: string + @ApiProperty({ type: Subpoena }) + readonly subpoena!: Subpoena } diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.controller.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.controller.ts index 7fc5ace19419..580c6187c5ad 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.controller.ts @@ -19,6 +19,9 @@ import { } from '@island.is/judicial-system/message' import { Case, CaseHasExistedGuard, CurrentCase } from '../case' +import { Subpoena } from '../subpoena' +import { CurrentSubpoena } from '../subpoena/guards/subpoena.decorator' +import { SubpoenaExistsGuard } from '../subpoena/guards/subpoenaExists.guard' import { CaseNotificationDto } from './dto/caseNotification.dto' import { InstitutionNotificationDto } from './dto/institutionNotification.dto' import { SubpoenaNotificationDto } from './dto/subpoenaNotification.dto' @@ -90,7 +93,7 @@ export class InternalNotificationController { return this.subpoenaNotificationService.sendNotification( notificationDto.type, - notificationDto.subpoenaId, + notificationDto.subpoena, ) } diff --git a/apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts index 82d7ef7acbdb..8a28b2e354b6 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/subpoenaNotification.service.ts @@ -15,7 +15,7 @@ import { NotificationType } from '@island.is/judicial-system/types' import { CaseService } from '../case' import { EventService } from '../event' -import { SubpoenaService } from '../subpoena' +import { Subpoena, SubpoenaService } from '../subpoena' import { DeliverResponse } from './models/deliver.response' import { Notification, Recipient } from './models/notification.model' import { BaseNotificationService } from './baseNotification.service' @@ -67,9 +67,8 @@ export class SubpoenaNotificationService extends BaseNotificationService { } } - private async getCase(subpoenaId: string) { - const subpoena = await this.subpoenaService.findBySubpoenaId(subpoenaId) - const theCase = await this.caseService.findById(subpoena.caseId) + private async getCase(caseId: string) { + const theCase = await this.caseService.findById(caseId) if (!theCase.courtCaseNumber) { throw new InternalServerErrorException( @@ -82,9 +81,9 @@ export class SubpoenaNotificationService extends BaseNotificationService { private async sendSubpoenaNotification( notificationType: subpoenaNotificationType, - subpoenaId: string, + subpoena: Subpoena, ): Promise { - const theCase = await this.getCase(subpoenaId) + const theCase = await this.getCase(subpoena.caseId) const hasSentSuccessfulServiceNotification = Boolean( this.hasSentNotification( @@ -179,13 +178,10 @@ export class SubpoenaNotificationService extends BaseNotificationService { async sendNotification( type: NotificationType, - subpoenaId: string, + subpoena: Subpoena, ): Promise { try { - this.sendSubpoenaNotification( - type as subpoenaNotificationType, - subpoenaId, - ) + this.sendSubpoenaNotification(type as subpoenaNotificationType, subpoena) } catch (error) { this.logger.error('Failed to send notification', error) diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts index a49de4ae5e2b..b7dd1e96d46d 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts @@ -149,7 +149,7 @@ export class SubpoenaService { type: MessageType.SUBPOENA_NOTIFICATION, body: { type: notificationType, - subpoenaId: subpoena.subpoenaId, + subpoena, }, }, ])