From 05a8419fb728b2698e3bf7c198e9b6e45e5280e8 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Thu, 10 Jun 2021 22:49:24 +0800 Subject: [PATCH] Fix internal error in uploading private images; fix #1317 --- .../src/commonMain/kotlin/contact/AbstractUser.kt | 10 +++++----- .../kotlin/network/protocol/data/proto/Cmd0x352.kt | 8 ++++---- .../network/protocol/packet/chat/image/LongConn.kt | 8 +++++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/contact/AbstractUser.kt b/mirai-core/src/commonMain/kotlin/contact/AbstractUser.kt index ca47440e3..438f86c2c 100644 --- a/mirai-core/src/commonMain/kotlin/contact/AbstractUser.kt +++ b/mirai-core/src/commonMain/kotlin/contact/AbstractUser.kt @@ -58,13 +58,13 @@ internal abstract class AbstractUser( val resp = bot.network.run { LongConn.OffPicUp( bot.client, Cmd0x352.TryUpImgReq( - srcUin = bot.id.toInt(), - dstUin = id.toInt(), - fileId = 0, + buType = 1, + srcUin = bot.id, + dstUin = this@AbstractUser.id, fileMd5 = resource.md5, - fileSize = resource.size.toInt(), + fileSize = resource.size, fileName = resource.md5.toUHexString("") + "." + resource.formatName, - imgOriginal = 1 + imgOriginal = 1, ) ).sendAndExpect() } diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/data/proto/Cmd0x352.kt b/mirai-core/src/commonMain/kotlin/network/protocol/data/proto/Cmd0x352.kt index 36effbb9a..d0dc0ef09 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/data/proto/Cmd0x352.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/data/proto/Cmd0x352.kt @@ -100,7 +100,7 @@ internal class Cmd0x352 : ProtoBuf { @ProtoNumber(2) @JvmField val msgTryupImgReq: List = emptyList(),// optional @ProtoNumber(3) @JvmField val msgGetimgUrlReq: List = emptyList(),// optional @ProtoNumber(4) @JvmField val msgDelImgReq: List = emptyList(), - @ProtoNumber(10) @JvmField val netType: Int = 3// 数据网络=5 + @ProtoNumber(10) @JvmField val netType: Int = 0// 数据网络=5, wifi=3 ) : ProtoBuf @Serializable @@ -115,11 +115,11 @@ internal class Cmd0x352 : ProtoBuf { @Serializable internal class TryUpImgReq( - @ProtoNumber(1) @JvmField val srcUin: Int, - @ProtoNumber(2) @JvmField val dstUin: Int, + @ProtoNumber(1) @JvmField val srcUin: Long, + @ProtoNumber(2) @JvmField val dstUin: Long, @ProtoNumber(3) @JvmField val fileId: Int = 0,//从0开始的自增数?貌似有一个连接就要自增1, 但是又会重置回0 @ProtoNumber(4) @JvmField val fileMd5: ByteArray, - @ProtoNumber(5) @JvmField val fileSize: Int, + @ProtoNumber(5) @JvmField val fileSize: Long, @ProtoNumber(6) @JvmField val fileName: String,//默认为md5+".jpg" @ProtoNumber(7) @JvmField val srcTerm: Int = 5, @ProtoNumber(8) @JvmField val platformType: Int = 9, diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/image/LongConn.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/image/LongConn.kt index b3d2f433f..227f5b1db 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/image/LongConn.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/image/LongConn.kt @@ -29,7 +29,13 @@ internal class LongConn { return buildOutgoingUniPacket(client) { writeProtoBuf( Cmd0x352.ReqBody.serializer(), - Cmd0x352.ReqBody(1, msgTryupImgReq = listOf(req)) + Cmd0x352.ReqBody( + subcmd = 1, + netType = 3, + msgTryupImgReq = listOf(req), + msgDelImgReq = listOf(), + msgGetimgUrlReq = listOf(), + ) ) } }