poller and release on end to frontend

This commit is contained in:
user
2026-03-28 20:10:44 +02:00
parent e525c657ac
commit 3e018d60f9
7 changed files with 196 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import {
UpdateLink,
} from "./data";
import { FlowExecCtx } from "@core/flow.execution.context";
import { errAsync, ResultAsync } from "neverthrow";
import { errAsync, okAsync, ResultAsync } from "neverthrow";
import { LinkRepository } from "./repository";
import { type Err } from "@pkg/result";
import { linkErrors } from "./errors";
@@ -54,6 +54,25 @@ export class LinkController {
});
}
/**
* Validate a token without updating lastAccessedAt.
* Useful for high-frequency polling paths.
*/
validateReadOnly(
fctx: FlowExecCtx,
token: string,
): ResultAsync<LinkWithDevice, Err> {
return this.repo.getByToken(fctx, token).andThen((l) => {
if (l.status !== LinkStatus.ACTIVE) {
return errAsync(linkErrors.linkNotActive(fctx, token));
}
if (l.expiresAt && l.expiresAt < new Date()) {
return errAsync(linkErrors.linkExpired(fctx, token));
}
return okAsync(l);
});
}
/**
* Generate a new link. Token is auto-generated as a URL-safe nanoid.
*/