Skip to content

Commit

Permalink
Merge branch 'main' into air-discount-scheme/myflug-and-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 30, 2024
2 parents 918210d + c0bb793 commit 864d0ea
Show file tree
Hide file tree
Showing 158 changed files with 3,622 additions and 2,122 deletions.
6 changes: 3 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export REDIS_CLUSTER_IP=0.0.0.0

source_env_if_exists .envrc.private
if [[ "${IS_DEVCONTAINER:-}" == true ]]; then
source_env_if_exists .devcontainer/.envrc.private
source_env_if_exists .devcontainer/.envrc.private || true
fi

# Podman compatibility
# NOTE: Exits direnv if user is using docker.
source_env_if_exists .envrc.podman
source_env_if_exists .envrc.podman || true

source_env_if_exists .envrc.kube
source_env_if_exists .envrc.kube || true
6 changes: 5 additions & 1 deletion .envrc.kube
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

for c in kubectx kubectl aws; do
if ! command -v "$c" >/dev/null; then
echo "$c not installed"
echo "Optional dependency $c not installed. Aborting automatic kube configuration"
return
fi
done
Expand All @@ -14,6 +14,10 @@ set-kubectx() {
if kubectx | grep -q "${AWS_PROFILE##islandis-}"; then
return
fi
if [[ -z "${AWS_PROFILE}" ]]; then
echo "No AWS_PROFILE set" >&2
return
fi
echo "Setting kube context..." >&2
AWS_ACCOUNT_ID="$(aws sts get-caller-identity | jq -r '.Account')"
kubectx "$(kubectx | grep "${AWS_ACCOUNT_ID}")"
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ codemagic.yaml
/libs/api/domains/university-gateway/ @island-is/origo
/libs/university-gateway/ @island-is/origo
/apps/web/screens/UniversitySearch/ @island-is/origo
/apps/web/screens/queries/UniversityGateway.ts @island-is/origo
/apps/web/components/ListViewCard/ @island-is/origo

/libs/application/templates/directorate-of-immigration/ @island-is/origo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ export class ApplicationController {
async delete(
@Param('id', new ParseUUIDPipe()) id: string,
@CurrentUser() user: User,
@CurrentLocale() locale: Locale,
) {
const { nationalId } = user
const existingApplication =
Expand All @@ -1097,6 +1098,53 @@ export class ApplicationController {
)
}

const template = await getApplicationTemplateByTypeId(
existingApplication.typeId,
)
if (template === null) {
throw new BadRequestException(
`No application template exists for type: ${existingApplication.typeId}`,
)
}

let onDeleteActions = new ApplicationTemplateHelper(
existingApplication,
template,
).getOnDeleteStateAPIAction()
if (onDeleteActions) {
const namespaces = await getApplicationTranslationNamespaces(
existingApplication,
)
if (!Array.isArray(onDeleteActions)) {
onDeleteActions = [onDeleteActions]
}

const intl = await this.intlService.useIntl(namespaces, locale)
const deletingApplication = await this.templateApiActionRunner.run(
existingApplication,
onDeleteActions,
user,
locale,
intl.formatMessage,
)

for (const api of onDeleteActions) {
const result =
deletingApplication.externalData[api.externalDataId || api.action]

this.logger.debug(
`Performing action ${api.action} on ${JSON.stringify(
template.name,
)} ended with ${result.status}`,
)

if (result.status === 'failure' && api.throwOnError) {
const reason = result.reason ?? 'Unknown error'
throw new TemplateApiError(reason, 500)
}
}
}

// delete charge in FJS
await this.applicationChargeService.deleteCharge(existingApplication)

Expand All @@ -1111,5 +1159,12 @@ export class ApplicationController {
)

await this.applicationService.delete(existingApplication.id)

this.auditService.audit({
auth: user,
action: 'delete',
resources: existingApplication.id,
meta: { type: existingApplication.typeId },
})
}
}
Loading

0 comments on commit 864d0ea

Please sign in to comment.