fix(protocol): avoid duplicate text for animated faces
Recognize animated face compatibility labels consistently while preserving user-authored text. Fixes #484
This commit is contained in:
2 files changed
+21
-1
No files matched your search
@@ -395,7 +395,7 @@ function bytesEqual(left: Uint8Array, right: Uint8Array): boolean {
|
||||
function isBigFaceCompatibilityText(extra: QFaceExtra, text: TextElem): boolean {
|
||||
const faceText = extra.text ?? '';
|
||||
const reserveData = text.pbReserve;
|
||||
if (!faceText.startsWith('/') || faceText.length === 1 || text.str !== faceText || !reserveData?.length) {
|
||||
if (!faceText || text.str !== faceText || !reserveData?.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -594,6 +594,26 @@ describe('decodeRichBody / unknown wire element observability', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it.each(['/打call', '[蛇年快乐]', 'name'])('recognizes native compatibility text independently of the face label prefix (%s)', (faceText) => {
|
||||
const reserve = protobuf_encode<TextElem>({
|
||||
str: `[${faceText.slice(1)}]请使用最新版手机QQ体验新功能`,
|
||||
});
|
||||
const body: MessageBody = {
|
||||
richText: {
|
||||
elems: [
|
||||
{ commonElem: { serviceType: 37, businessType: 3,
|
||||
pbElem: protobuf_encode<QFaceExtra>({ qsid: 429, text: faceText }) } } as never,
|
||||
{ text: { str: faceText, pbReserve: reserve } } as never,
|
||||
{ text: { str: faceText } } as never,
|
||||
],
|
||||
},
|
||||
};
|
||||
expect(decodeRichBody(body, false)).toEqual([
|
||||
{ type: 'face', faceId: 429 },
|
||||
{ type: 'text', text: faceText },
|
||||
]);
|
||||
});
|
||||
|
||||
it('[#289] preserves compatibility text when the big face has no valid face id', () => {
|
||||
const body: MessageBody = {
|
||||
richText: {
|
||||
|
||||
Reference in new issue
Block a user