From 1fd10567568eb9eb2f2a3aaa73024edb1aeca19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitja=20Bezen=C5=A1ek?= Date: Thu, 23 Jan 2025 16:03:00 +0100 Subject: [PATCH] Fix an issue with legacy assets not getting their urls changed when they get slurped. (#5270) Looks like this change was lost (might have forgot to push it). ### Change type - [x] `bugfix` --- apps/dotcom/sync-worker/src/TLDrawDurableObject.ts | 7 +++++++ apps/dotcom/sync-worker/src/types.ts | 1 + internal/scripts/deploy-dotcom.ts | 1 + 3 files changed, 9 insertions(+) diff --git a/apps/dotcom/sync-worker/src/TLDrawDurableObject.ts b/apps/dotcom/sync-worker/src/TLDrawDurableObject.ts index a34de21c3fe2..14d2f885fe7d 100644 --- a/apps/dotcom/sync-worker/src/TLDrawDurableObject.ts +++ b/apps/dotcom/sync-worker/src/TLDrawDurableObject.ts @@ -613,6 +613,13 @@ export class TLDrawDurableObject extends DurableObject { httpMetadata: currentAsset.httpMetadata, }) asset.props.src = asset.props.src.replace(objectName, newObjectName) + if (asset.props.src.includes(this.env.ASSET_UPLOAD_ORIGIN)) { + asset.props.src.replace( + this.env.ASSET_UPLOAD_ORIGIN, + `${this.env.MULTIPLAYER_SERVER}/api/app` + ) + } + asset.meta.fileId = slug store.put(asset) assetsToUpdate.push({ objectName: newObjectName, fileId: slug }) diff --git a/apps/dotcom/sync-worker/src/types.ts b/apps/dotcom/sync-worker/src/types.ts index aca3fde32f84..3679048bfa19 100644 --- a/apps/dotcom/sync-worker/src/types.ts +++ b/apps/dotcom/sync-worker/src/types.ts @@ -54,6 +54,7 @@ export interface Environment { IS_LOCAL: string | undefined WORKER_NAME: string | undefined ASSET_UPLOAD_ORIGIN: string | undefined + MULTIPLAYER_SERVER: string | undefined RATE_LIMITER: RateLimit } diff --git a/internal/scripts/deploy-dotcom.ts b/internal/scripts/deploy-dotcom.ts index f49dd1bf5c64..955bba4fa7e6 100644 --- a/internal/scripts/deploy-dotcom.ts +++ b/internal/scripts/deploy-dotcom.ts @@ -239,6 +239,7 @@ async function deployTlsyncWorker({ dryRun }: { dryRun: boolean }) { CLERK_PUBLISHABLE_KEY: env.VITE_CLERK_PUBLISHABLE_KEY, BOTCOM_POSTGRES_CONNECTION_STRING, BOTCOM_POSTGRES_POOLED_CONNECTION_STRING, + MULTIPLAYER_SERVER: env.MULTIPLAYER_SERVER, }, sentry: { project: 'tldraw-sync',