Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
refactor(session): remove the unused ownedByOtherLiveNode
Yudhi Armyndharisb9ca71b699c7
diff --git a/src/modules/session/session-ownership.service.spec.ts b/src/modules/session/session-ownership.service.spec.tsindex 1ae083370..ea188d9fc 100644--- a/src/modules/session/session-ownership.service.spec.ts+++ b/src/modules/session/session-ownership.service.spec.ts@@ -576,36 +576,6 @@ describe('SessionOwnershipService', () => {});});- describe('what a booting process may reset', () => {- const now = new Date();-- it('leaves alone a session another node holds on a live lease', () => {- expect(- service('node-b').ownedByOtherLiveNode(- { nodeId: 'node-a', leaseExpiresAt: new Date(now.getTime() + 60_000) },- now,- ),- ).toBe(true);- });-- it('reclaims its own rows, which really are dead after a restart', () => {- expect(- service('node-a').ownedByOtherLiveNode(- { nodeId: 'node-a', leaseExpiresAt: new Date(now.getTime() + 60_000) },- now,- ),- ).toBe(false);- });-- it('reclaims an unowned row and one whose lease has lapsed', () => {- const node = service('node-b');- expect(node.ownedByOtherLiveNode({ nodeId: null, leaseExpiresAt: null }, now)).toBe(false);- expect(node.ownedByOtherLiveNode({ nodeId: 'node-a', leaseExpiresAt: new Date(now.getTime() - 1) }, now)).toBe(- false,- );- });- });-/*** Drives an operator-facing warning during a data import: this process can only stop its own* engines, so a session running elsewhere has to be named rather than quietly counted as handled.diff --git a/src/modules/session/session-ownership.service.ts b/src/modules/session/session-ownership.service.tsindex ddd2f8047..d5bd7226a 100644--- a/src/modules/session/session-ownership.service.ts+++ b/src/modules/session/session-ownership.service.ts@@ -445,12 +445,6 @@ export class SessionOwnershipService {);}- /** For the boot reset, which must run before anything is claimed. */- ownedByOtherLiveNode(session: Pick<Session, 'nodeId' | 'leaseExpiresAt'>, now = new Date()): boolean {- if (!session.nodeId || session.nodeId === this.nodeId) return false;- return session.leaseExpiresAt != null && session.leaseExpiresAt > now;- }-/*** Sessions another node held whose lease has lapsed — a crashed peer, or this node's own* previous identity after a container recreate (the default nodeId is the hostname, which a