fix(server): get doc diff from doc service (#10067)

close CLOUD-121

avoid sync server to merge doc updates

before

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/hTwOityLamd4hitrae7M/054bf532-845d-427b-8cc4-f29e56f65720.png)

after

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/hTwOityLamd4hitrae7M/fafe9244-c521-4af0-b131-5a6092eb5a16.png)
This commit is contained in:
fengmk2
2025-02-12 10:20:23 +00:00
parent 30612de1ad
commit db8557eafb
10 changed files with 384 additions and 46 deletions
@@ -5,6 +5,7 @@ import type { ArgumentsHost, ExecutionContext } from '@nestjs/common';
import type { GqlContextType } from '@nestjs/graphql';
import { GqlArgumentsHost } from '@nestjs/graphql';
import type { Request, Response } from 'express';
import { ClsServiceManager } from 'nestjs-cls';
import type { Socket } from 'socket.io';
export function getRequestResponseFromHost(host: ArgumentsHost) {
@@ -87,9 +88,16 @@ export function parseCookies(
* - `ws`: websocket request
* - `se`: server event
* - `job`: cron job
* - `rpc`: rpc request
*/
export type RequestType = 'req' | 'ws' | 'se' | 'job';
export type RequestType = 'req' | 'ws' | 'se' | 'job' | 'rpc';
export function genRequestId(type: RequestType) {
return `${AFFiNE.flavor.type}:${type}-${randomUUID()}`;
}
export function getOrGenRequestId(type: RequestType) {
// The request id must exist in a cls context,
// but it can be lost in unexpected scenarios, such as unit tests, where it is automatically generated.
return ClsServiceManager.getClsService()?.getId() ?? genRequestId(type);
}