Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: do not create hash in frontend (#6788)

pengx1712806b0e7b6f
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts
index 5f08c964bc..6dafab51aa 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/request.ts
@@ -8,16 +8,6 @@ const TIMEOUT = 50000;
const client = new CopilotClient();
-async function calculateBlobHash(blob: Blob) {
- const buffer = await blob.arrayBuffer();
- const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
- const hashArray = Array.from(new Uint8Array(hashBuffer));
- return hashArray
- .map(byte => byte.toString(16).padStart(2, '0'))
- .join('')
- .slice(0, 32);
-}
-
export type TextToTextOptions = {
docId: string;
workspaceId: string;
@@ -86,7 +76,7 @@ async function createSessionMessage({
if (blob instanceof File) {
return blob;
} else {
- return new File([blob], await calculateBlobHash(blob), {
+ return new File([blob], sessionId, {
type: blob.type,
});
}