Skip to content

Commit

Permalink
adding delete async func
Browse files Browse the repository at this point in the history
  • Loading branch information
sigruntg committed Nov 8, 2024
1 parent 3bdec81 commit 8193d16
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
MachinesWithTotalCount,
WorkMachinesClientService,
} from '@island.is/clients/work-machines'
import { User } from '@island.is/auth-nest-tools'
@Injectable()
export class TransferOfMachineOwnershipTemplateService extends BaseTemplateApiService {
constructor(
Expand Down Expand Up @@ -270,6 +271,17 @@ export class TransferOfMachineOwnershipTemplateService extends BaseTemplateApiSe
return null
}

private async deleteOwnerChange(
auth: User,
applicationId: string,
): Promise<void> {
const deleteChange = {
ownerchangeId: applicationId,
xCorrelationID: applicationId,
}
await this.workMachineClientService.deleteOwnerChange(auth, deleteChange)
}

async deleteApplication({
application,
auth,
Expand All @@ -281,11 +293,7 @@ export class TransferOfMachineOwnershipTemplateService extends BaseTemplateApiSe
}

// 2. Delete owner change in work machines
const deleteChange = {
ownerchangeId: application.id,
xCorrelationID: application.id,
}
await this.workMachineClientService.deleteOwnerChange(auth, deleteChange)
await this.deleteOwnerChange(auth, application.id)

// 3. Notify everyone in the process that the application has been withdrawn

Expand Down Expand Up @@ -353,11 +361,7 @@ export class TransferOfMachineOwnershipTemplateService extends BaseTemplateApiSe
}

// 2. Delete owner change in work machines
const deleteChange = {
ownerchangeId: application.id,
xCorrelationID: application.id,
}
await this.workMachineClientService.deleteOwnerChange(auth, deleteChange)
await this.deleteOwnerChange(auth, application.id)

// 3. Notify everyone in the process that the application has been withdrawn

Expand Down

0 comments on commit 8193d16

Please sign in to comment.