From dcae9353ab09e74b01be9cf67365c6557e68a4cb Mon Sep 17 00:00:00 2001 From: Folist Date: Fri, 16 Oct 2026 10:54:12 +0300 Subject: [PATCH] =?UTF-8?q?1.3.10-beta.1:=20=D0=92=D0=A0=D0=95=D0=9C=D0=95?= =?UTF-8?q?=D0=9D=D0=9D=D0=90=D0=AF=20=D0=B4=D0=B8=D0=B0=D0=B3=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D0=BA=D0=B0=20PHOTO=5FCOMPARE=3D1=20(=D1=82?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D1=82=D0=B5=D1=81=D1=82)=20?= =?UTF-8?q?=E2=80=94=20=D0=BA=D0=B0=D0=B6=D0=B4=D0=BE=D0=B5=20=D1=84=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=20=D0=B8=D0=B7=20MAX=20=D0=BA=D0=B0=D1=87=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=8F=20=D0=B2=D1=81=D0=B5=D0=BC=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=D0=B0=D0=BC=D0=B8=20(baseU?= =?UTF-8?q?rl+token,=20baseUrl,=20url,=20baseUrl&fn=3Dw=5F1440)=20=D0=B8?= =?UTF-8?q?=20=D0=B2=20=D0=BB=D0=BE=D0=B3=20=D0=B8=D0=B4=D1=83=D1=82=20?= =?UTF-8?q?=D0=BE=D1=82=D0=B2=D0=B5=D1=82,=20=D0=B1=D0=B0=D0=B9=D1=82?= =?UTF-8?q?=D1=8B,=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82,=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D1=80=20=E2=80=94=20=D1=87=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=20=D1=80=D0=B5=D1=88=D0=B8=D1=82=D1=8C,=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9=20=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=BC;=20=D1=83=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B4=D0=BE=20=D0=B2=D1=8B=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 ++-- package.json | 2 +- src/bridge/attachments.ts | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f432c7a..d22b0c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "telemax", - "version": "1.3.9", + "version": "1.3.10-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "telemax", - "version": "1.3.9", + "version": "1.3.10-beta.1", "license": "AGPL-3.0-only", "dependencies": { "dotenv": "^17.2.3", diff --git a/package.json b/package.json index 1b55930..a1e7493 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "telemax", "private": true, "license": "AGPL-3.0-only", - "version": "1.3.9", + "version": "1.3.10-beta.1", "type": "module", "scripts": { "dev": "tsx watch src/server/app.ts", diff --git a/src/bridge/attachments.ts b/src/bridge/attachments.ts index 4bceee6..d6bb028 100644 --- a/src/bridge/attachments.ts +++ b/src/bridge/attachments.ts @@ -374,8 +374,32 @@ export function photoUrls(att: Pick !!v.url && all.findIndex((w) => w.url === v.url) === i); } +/** + * TEMPORARY diagnostic (PHOTO_COMPARE=1, test server only, 2026-10-16): fetches a MAX photo every + * way — photoUrls plus MAX web's on-screen size (`&fn=w_1440`) — and logs what each gives, to settle + * which way goes first. Remove before the release. + */ +async function comparePhotoUrls(att: MaxAttachment): Promise { + const id = String(att.photoId ?? '?'); + const declared = att as { width?: unknown; height?: unknown }; + logger.info(`PHOTO_COMPARE ${id}: MAX says ${String(declared.width)}×${String(declared.height)}`); + const ways = [...photoUrls(att)]; + if (att.baseUrl) ways.push({ how: 'baseUrl&fn=w_1440', url: `${att.baseUrl}&fn=w_1440` }); + for (const { how, url } of ways) { + try { + const res = await maxFetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) }); + const buf = res.ok ? Buffer.from(await res.arrayBuffer()) : undefined; + const size = buf ? imageSize(buf) : null; + logger.info(`PHOTO_COMPARE ${id}: «${how}» → ${res.status}${buf ? `, ${buf.byteLength} bytes, ${imageExtension(buf)}${size ? `, ${size.width}×${size.height}` : ''}` : ''}`); + } catch (err) { + logger.info(`PHOTO_COMPARE ${id}: «${how}» → ${(err as Error).message}`); + } + } +} + /** A photo by the first of photoUrls that the CDN gives — the next one tried only after a refusal (an outage is no reason to). */ async function downloadPhoto(att: MaxAttachment): Promise { + if (process.env.PHOTO_COMPARE === '1') void comparePhotoUrls(att); let miss: DownloadMissError | undefined; for (const { how, url } of photoUrls(att)) { try {