Skip to content

Commit

Permalink
Chore/simplify code (#290)
Browse files Browse the repository at this point in the history
* chore: remove unused variable

* chore: simplify AutoAcceptPendingRelationshipsModule
  • Loading branch information
jkoenig134 authored Oct 24, 2024
1 parent 433a3c0 commit 50e67ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ import { ConnectorRuntimeModule, ConnectorRuntimeModuleConfiguration } from "../
export interface AutoAcceptPendingRelationshipsModuleConfiguration extends ConnectorRuntimeModuleConfiguration {}

export default class AutoAcceptPendingRelationshipsModule extends ConnectorRuntimeModule<AutoAcceptPendingRelationshipsModuleConfiguration> {
private currentIdentity: string;

public init(): void {
// Nothing to do here
}

public async start(): Promise<void> {
const currentIdentityResult = await this.runtime.getServices().transportServices.account.getIdentityInfo();
this.currentIdentity = currentIdentityResult.value.address;

public start(): void {
this.subscribeToEvent(RelationshipChangedEvent, this.handleRelationshipChanged.bind(this));
}

Expand All @@ -32,12 +27,11 @@ export default class AutoAcceptPendingRelationshipsModule extends ConnectorRunti
}

private isIncomingPendingRelationship(event: RelationshipChangedEvent) {
const data = event.data;
if (data.status !== RelationshipStatus.Pending) return false;
if (data.auditLog.length !== 1) return false;
const relationship = event.data;
if (relationship.status !== RelationshipStatus.Pending) return false;
if (relationship.auditLog.length !== 1) return false;

const auditLogEntry = data.auditLog[0];
return auditLogEntry.createdBy !== this.currentIdentity;
return relationship.auditLog[0].createdBy !== event.eventTargetAddress;
}

public stop(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ import { ConnectorRuntimeModule, ConnectorRuntimeModuleConfiguration } from "../
export interface AutoDecomposeDeletionProposedRelationshipsModuleConfiguration extends ConnectorRuntimeModuleConfiguration {}

export default class AutoDecomposeDeletionProposedRelationshipsModule extends ConnectorRuntimeModule<AutoDecomposeDeletionProposedRelationshipsModuleConfiguration> {
private currentIdentity: string;

public init(): void {
// Nothing to do here
}

public async start(): Promise<void> {
const currentIdentityResult = await this.runtime.getServices().transportServices.account.getIdentityInfo();
this.currentIdentity = currentIdentityResult.value.address;

await this.decomposeDeletionProposedRelationshipsAtStartup();

this.subscribeToEvent(RelationshipChangedEvent, this.handleRelationshipChanged.bind(this));
Expand Down

0 comments on commit 50e67ad

Please sign in to comment.