clan-lib: Remove injected "op_key" argument from all functions and do it over the threadcontext instead. Remove double threading in http server

This commit is contained in:
Qubasa
2025-07-24 14:25:05 +07:00
parent 0ffad32657
commit 94662b722d
7 changed files with 80 additions and 60 deletions

View File

@@ -20,6 +20,7 @@ export type SuccessData<T extends OperationNames> = SuccessQuery<T>["data"];
interface SendHeaderType {
logging?: { group_path: string[] };
op_key?: string;
}
interface BackendSendType<K extends OperationNames> {
body: OperationArgs<K>;
@@ -64,9 +65,14 @@ export const callApi = <K extends OperationNames>(
};
}
const req: BackendSendType<OperationNames> = {
const op_key = backendOpts?.op_key ?? crypto.randomUUID();
let req: BackendSendType<OperationNames> = {
body: args,
header: backendOpts,
header: {
...backendOpts,
op_key,
},
};
const result = (
@@ -78,9 +84,6 @@ export const callApi = <K extends OperationNames>(
>
)[method](req) as Promise<BackendReturnType<K>>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const op_key = (result as any)._webviewMessageId as string;
return {
uuid: op_key,
result: result.then(({ body }) => body),