mirror of
https://github.com/immich-app/immich.git
synced 2025-08-05 08:42:27 -04:00
fix: sync set ack validation (#16320)
This commit is contained in:
parent
4ef7eb56a3
commit
5053130e35
@ -1,4 +1,4 @@
|
|||||||
import { ForbiddenException, Injectable } from '@nestjs/common';
|
import { BadRequestException, ForbiddenException, Injectable } from '@nestjs/common';
|
||||||
import { Insertable } from 'kysely';
|
import { Insertable } from 'kysely';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { Writable } from 'node:stream';
|
import { Writable } from 'node:stream';
|
||||||
@ -43,8 +43,6 @@ export class SyncService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setAcks(auth: AuthDto, dto: SyncAckSetDto) {
|
async setAcks(auth: AuthDto, dto: SyncAckSetDto) {
|
||||||
// TODO ack validation
|
|
||||||
|
|
||||||
const sessionId = auth.session?.id;
|
const sessionId = auth.session?.id;
|
||||||
if (!sessionId) {
|
if (!sessionId) {
|
||||||
return throwSessionRequired();
|
return throwSessionRequired();
|
||||||
@ -53,6 +51,10 @@ export class SyncService extends BaseService {
|
|||||||
const checkpoints: Insertable<SessionSyncCheckpoints>[] = [];
|
const checkpoints: Insertable<SessionSyncCheckpoints>[] = [];
|
||||||
for (const ack of dto.acks) {
|
for (const ack of dto.acks) {
|
||||||
const { type } = fromAck(ack);
|
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 });
|
checkpoints.push({ sessionId, type, ack });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user