Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 89dba7b

Browse files
authored
[core] fix send image subtype (#818)
1 parent 8681bf0 commit 89dba7b

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

Lagrange.Core/Internal/Packets/Service/Oidb/Common/NTV2RichMediaReq.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ internal class PicExtBizInfo
297297

298298
[ProtoMember(2)] public string TextSummary { get; set; }
299299

300-
[ProtoMember(11)] public byte[]? BytesPbReserveC2c { get; set; }
300+
[ProtoMember(11)] public PicExtBizInfoC2c? C2c { get; set; }
301301

302-
[ProtoMember(12)] public byte[]? BytesPbReserveTroop { get; set; }
302+
[ProtoMember(12)] public PicExtBizInfoTroop? Troop { get; set; }
303303

304304
[ProtoMember(1001)] public uint FromScene { get; set; }
305305

@@ -308,6 +308,18 @@ internal class PicExtBizInfo
308308
[ProtoMember(1003)] public uint OldFileId { get; set; }
309309
}
310310

311+
[ProtoContract]
312+
internal class PicExtBizInfoC2c
313+
{
314+
[ProtoMember(1)] public uint SubType { get; set; }
315+
}
316+
317+
[ProtoContract]
318+
internal class PicExtBizInfoTroop
319+
{
320+
[ProtoMember(1)] public uint SubType { get; set; }
321+
}
322+
311323
[ProtoContract]
312324
internal class DownloadSafeReq
313325
{

Lagrange.Core/Internal/Service/Message/ImageGroupUploadService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,15 @@ protected override bool Build(ImageGroupUploadEvent input, BotKeystore keystore,
9292
{
9393
Pic = new PicExtBizInfo
9494
{
95-
TextSummary = input.Entity.Summary!,
96-
BytesPbReserveTroop = "0800180020004a00500062009201009a0100aa010c080012001800200028003a00".UnHex()
95+
BizType = (uint)input.Entity.SubType,
96+
// This is very confusing
97+
// so we only implement the default summary for sub type 1
98+
// and Tencent implements the others based on the default values.
99+
TextSummary = input.Entity.Summary ?? (input.Entity.SubType == 1 ? "[\u52a8\u753b\u8868\u60c5]" : null!),
100+
C2c = new PicExtBizInfoC2c
101+
{
102+
SubType = (uint)input.Entity.SubType
103+
}
97104
},
98105
Video = new VideoExtBizInfo { BytesPbReserve = Array.Empty<byte>() },
99106
Ptt = new PttExtBizInfo

Lagrange.Core/Internal/Service/Message/ImageUploadService.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ protected override bool Build(ImageUploadEvent input, BotKeystore keystore, BotA
1919
BotDeviceInfo device, out Span<byte> output, out List<Memory<byte>>? extraPackets)
2020
{
2121
if (input.Entity.ImageStream is null) throw new Exception();
22-
22+
2323
string md5 = input.Entity.ImageStream.Value.Md5(true);
2424
string sha1 = input.Entity.ImageStream.Value.Sha1(true);
25-
25+
2626
var buffer = new byte[1024]; // parse image header
2727
int _ = input.Entity.ImageStream.Value.Read(buffer.AsSpan());
2828
var type = ImageResolver.Resolve(buffer, out var size);
@@ -97,8 +97,14 @@ protected override bool Build(ImageUploadEvent input, BotKeystore keystore, BotA
9797
{
9898
Pic = new PicExtBizInfo
9999
{
100-
TextSummary = input.Entity.Summary!,
101-
BytesPbReserveC2c = "0800180020004200500062009201009a0100a2010c080012001800200028003a00".UnHex()
100+
BizType = (uint)input.Entity.SubType,
101+
// This is very confusing, so we only implement the default summary for sub type 1
102+
// and Tencent implements the others based on the default values.
103+
TextSummary = input.Entity.Summary ?? (input.Entity.SubType == 1 ? "[\u52a8\u753b\u8868\u60c5]" : null!),
104+
C2c = new PicExtBizInfoC2c
105+
{
106+
SubType = (uint)input.Entity.SubType
107+
}
102108
},
103109
Video = new VideoExtBizInfo { BytesPbReserve = Array.Empty<byte>() },
104110
Ptt = new PttExtBizInfo
@@ -112,7 +118,7 @@ protected override bool Build(ImageUploadEvent input, BotKeystore keystore, BotA
112118
NoNeedCompatMsg = false
113119
}
114120
}, 0x11c5, 100, false, true);
115-
121+
116122
output = packet.Serialize();
117123
extraPackets = null;
118124
return true;
@@ -124,7 +130,7 @@ protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo
124130
var packet = Serializer.Deserialize<OidbSvcTrpcTcpBase<NTV2RichMediaResp>>(input);
125131
var upload = packet.Body.Upload;
126132
var compat = Serializer.Deserialize<NotOnlineImage>(upload.CompatQMsg.AsSpan());
127-
133+
128134
output = ImageUploadEvent.Result((int)packet.ErrorCode, upload.MsgInfo, upload.UKey, upload.IPv4s, upload.SubFileInfos, compat);
129135
extraEvents = null;
130136
return true;

0 commit comments

Comments
 (0)