Skip to content

Commit

Permalink
fix: fixed type issue with rpc handler preventing building
Browse files Browse the repository at this point in the history
  • Loading branch information
CDeltakai committed Feb 25, 2025
1 parent 364237b commit a04adea
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/nodes/agent/handlers/NodesAuditEventsGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type Audit from '../../../audit/Audit';
import type { AuditEvent } from '../../../audit/types';
import { ServerHandler } from '@matrixai/rpc';
import * as auditUtils from '../../../audit/utils';
import { AuditEventId } from '@/ids';

/**
* Gets audit events from a node
Expand All @@ -29,12 +30,16 @@ class NodesAuditEventsGet extends ServerHandler<
_meta: Record<string, JSONValue> | undefined,
ctx: ContextTimed,
): AsyncGenerator<AgentRPCResponseResult<AgentAuditMessage<AuditEvent>>> {
let { seek, seekEnd, limit } = input;
let seek_: AuditEventId | number | undefined;
let seekEnd_: AuditEventId | number | undefined;

const { seek, seekEnd, limit } = input;

if (typeof seek !== 'number') {
seek = auditUtils.decodeAuditEventId(seek);
seek_ = auditUtils.decodeAuditEventId(seek);
}
if (typeof seekEnd !== 'number') {
seekEnd = auditUtils.decodeAuditEventId(seekEnd);
seekEnd_ = auditUtils.decodeAuditEventId(seekEnd);
}

const { audit, db }: { audit: Audit; db: DB } = this.container;
Expand All @@ -45,17 +50,17 @@ class NodesAuditEventsGet extends ServerHandler<
for await (const auditEvent of audit.getAuditEvents(
[],
{
seek,
seekEnd,
seek : seek_,
seekEnd : seekEnd_,
limit,
},
tran,
)) {
ctx.signal.throwIfAborted();
// Skip the seek event to ensure exclusivity if given an AuditEventId
// This assumes that ids are unique
if (seek !== undefined) {
if (typeof seek !== 'number' && auditEvent.id.equals(seek)) {
if (seek_ !== undefined) {
if (typeof seek_ !== 'number' && auditEvent.id.equals(seek_)) {
continue;
}
}
Expand Down

0 comments on commit a04adea

Please sign in to comment.