poller and release on end to frontend
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user