From 85d5bf4125b8c4c5bd1fc91a2c1e5d0cf0600405 Mon Sep 17 00:00:00 2001 From: Shaya Potter Date: Tue, 18 Jun 2024 17:01:41 +0300 Subject: [PATCH] add CLIENT KILL MAXAGE (v5) (#2760) * add CLIENT KILL MANAGE maxAge (v5) * replace "MANAGE" with "MAXAGE" * fix test --------- Co-authored-by: Leibale Eidelman --- packages/client/lib/commands/CLIENT_KILL.spec.ts | 10 ++++++++++ packages/client/lib/commands/CLIENT_KILL.ts | 13 +++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/client/lib/commands/CLIENT_KILL.spec.ts b/packages/client/lib/commands/CLIENT_KILL.spec.ts index 0685c46ba4..79254af41f 100644 --- a/packages/client/lib/commands/CLIENT_KILL.spec.ts +++ b/packages/client/lib/commands/CLIENT_KILL.spec.ts @@ -65,6 +65,16 @@ describe('CLIENT KILL', () => { ); }); + it('MAXAGE', () => { + assert.deepEqual( + CLIENT_KILL.transformArguments({ + filter: CLIENT_KILL_FILTERS.MAXAGE, + maxAge: 10 + }), + ['CLIENT', 'KILL', 'MAXAGE', '10'] + ); + }); + describe('SKIP_ME', () => { it('undefined', () => { assert.deepEqual( diff --git a/packages/client/lib/commands/CLIENT_KILL.ts b/packages/client/lib/commands/CLIENT_KILL.ts index 81d0bc85ee..acf538f9a5 100644 --- a/packages/client/lib/commands/CLIENT_KILL.ts +++ b/packages/client/lib/commands/CLIENT_KILL.ts @@ -6,7 +6,8 @@ export const CLIENT_KILL_FILTERS = { ID: 'ID', TYPE: 'TYPE', USER: 'USER', - SKIP_ME: 'SKIPME' + SKIP_ME: 'SKIPME', + MAXAGE: 'MAXAGE' } as const; type CLIENT_KILL_FILTERS = typeof CLIENT_KILL_FILTERS; @@ -39,7 +40,11 @@ export type ClientKillSkipMe = CLIENT_KILL_FILTERS['SKIP_ME'] | (ClientKillFilte skipMe: boolean; }); -export type ClientKillFilter = ClientKillAddress | ClientKillLocalAddress | ClientKillId | ClientKillType | ClientKillUser | ClientKillSkipMe; +export interface ClientKillMaxAge extends ClientKillFilterCommon { + maxAge: number; +} + +export type ClientKillFilter = ClientKillAddress | ClientKillLocalAddress | ClientKillId | ClientKillType | ClientKillUser | ClientKillSkipMe | ClientKillMaxAge; export default { FIRST_KEY_INDEX: undefined, @@ -96,5 +101,9 @@ function pushFilter(args: Array, filter: ClientKillFilter): void case CLIENT_KILL_FILTERS.SKIP_ME: args.push(filter.skipMe ? 'yes' : 'no'); break; + + case CLIENT_KILL_FILTERS.MAXAGE: + args.push(filter.maxAge.toString()); + break; } }