mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
fix(adapters): drop HEIC mime, align Telegram error text, inline extractText
This commit is contained in:
parent
30b9370a43
commit
6bcbbc547f
@ -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)
|
||||
|
||||
@ -14,7 +14,6 @@ export const IMAGE_MIME_WHITELIST = [
|
||||
'image/png',
|
||||
'image/gif',
|
||||
'image/webp',
|
||||
'image/heic',
|
||||
] as const
|
||||
|
||||
export type LimitCheckResult =
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -637,7 +637,7 @@ async function collectAttachmentsFromCtx(
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[Telegram] downloadFile failed:', err)
|
||||
rejections.push('📎 附件下载失败')
|
||||
rejections.push('📎 附件下载失败,请稍后重试')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user