fix(adapters): drop HEIC mime, align Telegram error text, inline extractText

This commit is contained in:
程序员阿江(Relakkes) 2026-04-11 16:19:07 +08:00
parent 30b9370a43
commit 6bcbbc547f
4 changed files with 9 additions and 9 deletions

View File

@ -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)

View File

@ -14,7 +14,6 @@ export const IMAGE_MIME_WHITELIST = [
'image/png',
'image/gif',
'image/webp',
'image/heic',
] as const
export type LimitCheckResult =

View File

@ -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<void> {
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) {

View File

@ -637,7 +637,7 @@ async function collectAttachmentsFromCtx(
}
} catch (err) {
console.error('[Telegram] downloadFile failed:', err)
rejections.push('📎 附件下载失败')
rejections.push('📎 附件下载失败,请稍后重试')
}
}