fix(dingtalk): don't let richText re-derivation clobber VOICE classification

The msg_type_str == "richText" branch reset msg_type to PHOTO/TEXT after
the rich-text item scan had already promoted it (e.g. a native voice item
→ VOICE), dropping voice notes from the auto-STT path. Only re-derive when
the scan left the type at TEXT.

Ports the root-cause analysis from PR #38276 (stale, targeted the deleted
gateway/platforms/dingtalk.py) onto the live plugin adapter, with
regression tests.

Refs #38211 #38219 #38276
This commit is contained in:
Teknium 2026-07-28 09:25:06 -07:00
parent c762314561
commit 7ee111ff9b
2 changed files with 43 additions and 5 deletions

View file

@ -920,11 +920,15 @@ class DingTalkAdapter(BasePlatformAdapter):
if msg_type_str == "picture" and not media_urls:
msg_type = MessageType.PHOTO
elif msg_type_str == "richText":
msg_type = (
MessageType.PHOTO
if any("image" in t for t in media_types)
else MessageType.TEXT
)
# Only re-derive the type when the rich-text scan above left it
# at TEXT. The scan may already have promoted it to VOICE/AUDIO/
# VIDEO/DOCUMENT for embedded media items — resetting those here
# dropped native voice notes back to TEXT and skipped STT
# (#38211, #38219; analysis from #38276).
if msg_type == MessageType.TEXT and any(
"image" in t for t in media_types
):
msg_type = MessageType.PHOTO
elif msg_type_str == "audio":
# Voice message — DingTalk already provides recognition text.
# Do NOT add media_urls here: if audio_paths is non-empty,