Skip to content

Commit

Permalink
fix: sync set ack validation (#16320)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackpollard authored Feb 26, 2025
1 parent 4ef7eb5 commit 5053130
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/src/services/sync.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ForbiddenException, Injectable } from '@nestjs/common';
import { BadRequestException, ForbiddenException, Injectable } from '@nestjs/common';
import { Insertable } from 'kysely';
import { DateTime } from 'luxon';
import { Writable } from 'node:stream';
Expand Down Expand Up @@ -43,8 +43,6 @@ export class SyncService extends BaseService {
}

async setAcks(auth: AuthDto, dto: SyncAckSetDto) {
// TODO ack validation

const sessionId = auth.session?.id;
if (!sessionId) {
return throwSessionRequired();
Expand All @@ -53,6 +51,10 @@ export class SyncService extends BaseService {
const checkpoints: Insertable<SessionSyncCheckpoints>[] = [];
for (const ack of dto.acks) {
const { type } = fromAck(ack);
// TODO proper ack validation via class validator
if (!Object.values(SyncEntityType).includes(type)) {
throw new BadRequestException(`Invalid ack type: ${type}`);
}
checkpoints.push({ sessionId, type, ack });
}

Expand Down

0 comments on commit 5053130

Please sign in to comment.