Browse Source

Share: sync

Frank 9 months ago
parent
commit
9b331a917e
2 changed files with 8 additions and 8 deletions
  1. 7 7
      app/packages/function/src/api.ts
  2. 1 1
      app/packages/web/src/app.tsx

+ 7 - 7
app/packages/function/src/api.ts

@@ -80,7 +80,7 @@ export default {
     }
     }
     if (request.method === "POST" && url.pathname.endsWith("/share_create")) {
     if (request.method === "POST" && url.pathname.endsWith("/share_create")) {
       const body = await request.json()
       const body = await request.json()
-      const sessionID = body.session_id
+      const sessionID = body.sessionID
       const shareID = createHash("sha256").update(sessionID).digest("hex")
       const shareID = createHash("sha256").update(sessionID).digest("hex")
       const infoFile = `${shareID}/info/${sessionID}.json`
       const infoFile = `${shareID}/info/${sessionID}.json`
       const ret = await Resource.Bucket.get(infoFile)
       const ret = await Resource.Bucket.get(infoFile)
@@ -89,14 +89,14 @@ export default {
 
 
       await Resource.Bucket.put(infoFile, "")
       await Resource.Bucket.put(infoFile, "")
 
 
-      return new Response(JSON.stringify({ share_id: shareID }), {
+      return new Response(JSON.stringify({ shareID }), {
         headers: { "Content-Type": "application/json" },
         headers: { "Content-Type": "application/json" },
       })
       })
     }
     }
     if (request.method === "POST" && url.pathname.endsWith("/share_delete")) {
     if (request.method === "POST" && url.pathname.endsWith("/share_delete")) {
       const body = await request.json()
       const body = await request.json()
-      const sessionID = body.session_id
-      const shareID = body.share_id
+      const sessionID = body.sessionID
+      const shareID = body.shareID
       const infoFile = `${shareID}/info/${sessionID}.json`
       const infoFile = `${shareID}/info/${sessionID}.json`
       await Resource.Bucket.delete(infoFile)
       await Resource.Bucket.delete(infoFile)
       return new Response(JSON.stringify({}), {
       return new Response(JSON.stringify({}), {
@@ -105,8 +105,8 @@ export default {
     }
     }
     if (request.method === "POST" && url.pathname.endsWith("/share_sync")) {
     if (request.method === "POST" && url.pathname.endsWith("/share_sync")) {
       const body = await request.json()
       const body = await request.json()
-      const sessionID = body.session_id
-      const shareID = body.share_id
+      const sessionID = body.sessionID
+      const shareID = body.shareID
       const key = body.key
       const key = body.key
       const content = body.content
       const content = body.content
 
 
@@ -142,7 +142,7 @@ export default {
       }
       }
 
 
       // get query parameters
       // get query parameters
-      const shareID = url.searchParams.get("share_id")
+      const shareID = url.searchParams.get("shareID")
       if (!shareID)
       if (!shareID)
         return new Response("Error: Share ID is required", { status: 400 })
         return new Response("Error: Share ID is required", { status: 400 })
 
 

+ 1 - 1
app/packages/web/src/app.tsx

@@ -45,7 +45,7 @@ export default function App() {
 
 
       // Always use secure WebSocket protocol (wss)
       // Always use secure WebSocket protocol (wss)
       const wsBaseUrl = apiUrl.replace(/^https?:\/\//, "wss://")
       const wsBaseUrl = apiUrl.replace(/^https?:\/\//, "wss://")
-      const wsUrl = `${wsBaseUrl}/share_poll?share_id=${shareId}`
+      const wsUrl = `${wsBaseUrl}/share_poll?shareID=${shareId}`
       console.log("Connecting to WebSocket URL:", wsUrl)
       console.log("Connecting to WebSocket URL:", wsUrl)
 
 
       // Create WebSocket connection
       // Create WebSocket connection