-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/block-sending-messages-to-a-deleted-…
…or-toBeDeleted-Identity
- Loading branch information
Showing
114 changed files
with
3,215 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
BACKBONE_VERSION=6.15.0 | ||
BACKBONE_VERSION=6.20.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# https://github.com/repository-settings/app | ||
|
||
repository: | ||
allow_squash_merge: true | ||
allow_merge_commit: false | ||
allow_rebase_merge: false | ||
allow_auto_merge: true | ||
allow_update_branch: true | ||
delete_branch_on_merge: true | ||
|
||
labels: | ||
- name: breaking-change | ||
color: "#16060F" | ||
description: A breaking change | ||
- name: bug | ||
color: "#d73a4a" | ||
description: Something isn't working | ||
- name: chore | ||
color: "#c2e0c6" | ||
description: Some routine work like updating dependencies | ||
- name: ci | ||
color: "#DFB5FD" | ||
description: Continuous Integration related stuff | ||
- name: dependencies | ||
color: "#0366d6" | ||
description: Pull requests that update dependencies | ||
- name: documentation | ||
color: "#0075ca" | ||
description: Improvements or additions to documentation | ||
- name: enhancement | ||
color: "#a2eeef" | ||
description: New feature or request | ||
- name: refactoring | ||
color: "#880361" | ||
description: Refactoring of code | ||
- name: test | ||
color: "#20D89D" | ||
description: This pull request contains only new or changed tests | ||
- name: wip | ||
color: "#32BF4C" | ||
description: Work in Progress (blocks mergify from auto update the branch) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
packages/app-runtime/src/events/DatawalletSynchronizedEvent.ts
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
packages/app-runtime/src/events/LocalAccountDeletionDateChangedEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { DataEvent } from "@nmshd/runtime"; | ||
import { LocalAccountDTO } from "../multiAccount"; | ||
|
||
export class LocalAccountDeletionDateChangedEvent extends DataEvent<LocalAccountDTO> { | ||
public static readonly namespace: string = "app.localAccountDeletionDateChanged"; | ||
|
||
public constructor(address: string, localAccount: LocalAccountDTO) { | ||
super(LocalAccountDeletionDateChangedEvent.namespace, address, localAccount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export * from "./AccountSelectedEvent"; | ||
export * from "./DatawalletSynchronizedEvent"; | ||
export * from "./ExternalEventReceivedEvent"; | ||
export * from "./LocalAccountDeletionDateChangedEvent"; | ||
export * from "./MailReceivedEvent"; | ||
export * from "./OnboardingChangeReceivedEvent"; | ||
export * from "./RelationshipSelectedEvent"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/app-runtime/src/modules/runtimeEvents/DatawalletSynchronizedModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { CoreDate } from "@nmshd/core-types"; | ||
import { DatawalletSynchronizedEvent, IdentityDeletionProcessStatus } from "@nmshd/runtime"; | ||
import { AppRuntimeError } from "../../AppRuntimeError"; | ||
import { LocalAccountDeletionDateChangedEvent } from "../../events"; | ||
import { LocalAccountMapper } from "../../multiAccount"; | ||
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule"; | ||
|
||
export interface DatawalletSynchronizedModuleConfig extends AppRuntimeModuleConfiguration {} | ||
|
||
export class DatawalletSynchronizedModuleError extends AppRuntimeError {} | ||
|
||
export class DatawalletSynchronizedModule extends AppRuntimeModule<DatawalletSynchronizedModuleConfig> { | ||
public async init(): Promise<void> { | ||
// Nothing to do here | ||
} | ||
|
||
public start(): Promise<void> | void { | ||
this.subscribeToEvent(DatawalletSynchronizedEvent, this.handleDatawalletSynchronized.bind(this)); | ||
} | ||
|
||
private async handleDatawalletSynchronized(event: DatawalletSynchronizedEvent) { | ||
const services = await this.runtime.getServices(event.eventTargetAddress); | ||
const identityDeletionProcessResult = await services.transportServices.identityDeletionProcesses.getIdentityDeletionProcesses(); | ||
|
||
if (identityDeletionProcessResult.isError) { | ||
this.logger.error(identityDeletionProcessResult); | ||
return; | ||
} | ||
|
||
if (identityDeletionProcessResult.value.length === 0) return; | ||
|
||
const mostRecentIdentityDeletionProcess = identityDeletionProcessResult.value.at(-1)!; | ||
let newDeletionDate; | ||
switch (mostRecentIdentityDeletionProcess.status) { | ||
case IdentityDeletionProcessStatus.Approved: | ||
newDeletionDate = CoreDate.from(mostRecentIdentityDeletionProcess.gracePeriodEndsAt!); | ||
break; | ||
case IdentityDeletionProcessStatus.Cancelled: | ||
case IdentityDeletionProcessStatus.Rejected: | ||
case IdentityDeletionProcessStatus.WaitingForApproval: | ||
newDeletionDate = undefined; | ||
break; | ||
} | ||
|
||
const account = await this.runtime.multiAccountController.getAccountByAddress(event.eventTargetAddress); | ||
const previousDeletionDate = account.deletionDate; | ||
|
||
if (previousDeletionDate === newDeletionDate) return; | ||
|
||
await this.runtime.multiAccountController.updateLocalAccountDeletionDate(event.eventTargetAddress, newDeletionDate); | ||
|
||
const updatedAccount = await this.runtime.multiAccountController.getAccountByAddress(event.eventTargetAddress); | ||
this.runtime.eventBus.publish(new LocalAccountDeletionDateChangedEvent(event.eventTargetAddress, LocalAccountMapper.toLocalAccountDTO(updatedAccount))); | ||
} | ||
|
||
public override stop(): Promise<void> | void { | ||
this.unsubscribeFromAllEvents(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/app-runtime/src/modules/runtimeEvents/IdentityDeletionProcessStatusChangedModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { CoreDate } from "@nmshd/core-types"; | ||
import { IdentityDeletionProcessStatus, IdentityDeletionProcessStatusChangedEvent } from "@nmshd/runtime"; | ||
import { AppRuntimeError } from "../../AppRuntimeError"; | ||
import { AppRuntimeModule, AppRuntimeModuleConfiguration } from "../AppRuntimeModule"; | ||
|
||
export interface IdentityDeletionProcessStatusChangedModuleConfig extends AppRuntimeModuleConfiguration {} | ||
|
||
export class IdentityDeletionProcessChangedModuleError extends AppRuntimeError {} | ||
|
||
export class IdentityDeletionProcessStatusChangedModule extends AppRuntimeModule<IdentityDeletionProcessStatusChangedModuleConfig> { | ||
public async init(): Promise<void> { | ||
// Nothing to do here | ||
} | ||
|
||
public start(): Promise<void> | void { | ||
this.subscribeToEvent(IdentityDeletionProcessStatusChangedEvent, this.handleIdentityDeletionProcessStatusChanged.bind(this)); | ||
} | ||
|
||
private async handleIdentityDeletionProcessStatusChanged(event: IdentityDeletionProcessStatusChangedEvent) { | ||
const identityDeletionProcess = event.data; | ||
|
||
switch (identityDeletionProcess.status) { | ||
case IdentityDeletionProcessStatus.Approved: | ||
await this.runtime.multiAccountController.updateLocalAccountDeletionDate(event.eventTargetAddress, CoreDate.from(identityDeletionProcess.gracePeriodEndsAt!)); | ||
break; | ||
|
||
case IdentityDeletionProcessStatus.Cancelled: | ||
const account = await this.runtime.multiAccountController.getAccountByAddress(event.eventTargetAddress); | ||
const previousDeletionDate = account.deletionDate; | ||
|
||
if (!previousDeletionDate) break; | ||
|
||
await this.runtime.multiAccountController.updateLocalAccountDeletionDate(event.eventTargetAddress, undefined); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
public override stop(): Promise<void> | void { | ||
this.unsubscribeFromAllEvents(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from "./DatawalletSynchronizedModule"; | ||
export * from "./IdentityDeletionProcessStatusChangedModule"; | ||
export * from "./MessageReceivedModule"; | ||
export * from "./RelationshipChangedModule"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.