From 6bcbbc547f8802faed930ca115f0b54524e1857d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Sat, 11 Apr 2026 16:19:07 +0800 Subject: [PATCH] fix(adapters): drop HEIC mime, align Telegram error text, inline extractText --- .../attachment/__tests__/attachment-limits.test.ts | 6 ++++++ adapters/common/attachment/attachment-limits.ts | 1 - adapters/feishu/index.ts | 9 ++------- adapters/telegram/index.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/adapters/common/attachment/__tests__/attachment-limits.test.ts b/adapters/common/attachment/__tests__/attachment-limits.test.ts index aa497d0e..32cea653 100644 --- a/adapters/common/attachment/__tests__/attachment-limits.test.ts +++ b/adapters/common/attachment/__tests__/attachment-limits.test.ts @@ -27,6 +27,12 @@ describe('checkAttachmentLimit', () => { if (!result.ok) expect(result.reason).toBe('unsupported_mime') }) + it('rejects image/heic (not supported by Claude API)', () => { + const result = checkAttachmentLimit('image', 500_000, 'image/heic') + expect(result.ok).toBe(false) + if (!result.ok) expect(result.reason).toBe('unsupported_mime') + }) + it('accepts a 10 MB PDF file', () => { const result = checkAttachmentLimit('file', 10 * 1024 * 1024, 'application/pdf') expect(result.ok).toBe(true) diff --git a/adapters/common/attachment/attachment-limits.ts b/adapters/common/attachment/attachment-limits.ts index 170ae231..c3e87287 100644 --- a/adapters/common/attachment/attachment-limits.ts +++ b/adapters/common/attachment/attachment-limits.ts @@ -14,7 +14,6 @@ export const IMAGE_MIME_WHITELIST = [ 'image/png', 'image/gif', 'image/webp', - 'image/heic', ] as const export type LimitCheckResult = diff --git a/adapters/feishu/index.ts b/adapters/feishu/index.ts index a788fb50..7544eddc 100644 --- a/adapters/feishu/index.ts +++ b/adapters/feishu/index.ts @@ -767,12 +767,7 @@ async function handleServerMessage(chatId: string, msg: ServerMessage): Promise< } } -// ---------- extract message text ---------- - -function extractText(content: string, msgType: string): string | null { - const { text } = extractInboundPayload(content, msgType) - return text.trim() || null -} +// ---------- message helpers ---------- function isBotMentioned(mentions?: Array<{ id?: { open_id?: string } }>): boolean { if (!mentions || !botOpenId) return false @@ -813,7 +808,7 @@ async function handleMessage(data: any): Promise { if (chatType === 'p2p') { if (!isAllowedUser('feishu', senderOpenId)) { // 尝试配对 - const pairText = extractText(content, msgType) + const pairText = extractInboundPayload(content, msgType).text.trim() || null if (pairText) { const success = tryPair(pairText.trim(), { userId: senderOpenId, displayName: 'Feishu User' }, 'feishu') if (success) { diff --git a/adapters/telegram/index.ts b/adapters/telegram/index.ts index e445467c..2943fb85 100644 --- a/adapters/telegram/index.ts +++ b/adapters/telegram/index.ts @@ -637,7 +637,7 @@ async function collectAttachmentsFromCtx( } } catch (err) { console.error('[Telegram] downloadFile failed:', err) - rejections.push('📎 附件下载失败') + rejections.push('📎 附件下载失败,请稍后重试') } }