fix(protocol): avoid duplicate private voice elements
Prefer a successfully decoded modern voice record over the empty legacy voice placeholder that can accompany private message pushes. Preserve legacy-only voice messages and add a protobuf round-trip regression covering the duplicate segment reported in #291. Fixes #291
This commit is contained in:
2 files changed
+56
-2
No files matched your search
@@ -870,8 +870,14 @@ function extractRichtextExtras(
|
||||
elements: MessageElement[],
|
||||
isGroup = false
|
||||
): void {
|
||||
// Ptt (voice)
|
||||
if (rt.ptt) {
|
||||
// QQ's PTT codec selects either the NTV2 CommonElem representation or the
|
||||
// legacy RichText.ptt representation. Some C2C pushes still carry an empty
|
||||
// legacy placeholder beside a complete NTV2 record; decoding both produces a
|
||||
// second, unusable voice segment (#291).
|
||||
const hasNtv2Record = elements.some((element) => element.type === 'record');
|
||||
|
||||
// Ptt (legacy voice)
|
||||
if (rt.ptt && !hasNtv2Record) {
|
||||
const p = rt.ptt;
|
||||
const md5Hex = p.fileMd5 && p.fileMd5.length > 0 ? toHexUpper(p.fileMd5) : undefined;
|
||||
const me: MessageElementOf<'record'> = {
|
||||
|
||||
Reference in new issue
Block a user