Image uploading logs

This commit is contained in:
Him188 2020-01-03 19:08:58 +08:00
parent 426c2c636b
commit bd74907f68

View File

@ -64,16 +64,17 @@ internal class GroupImpl internal constructor(bot: TIMPCBot, val groupId: GroupI
withContext(userContext) { withContext(userContext) {
when (response) { when (response) {
is ImageUploadInfo -> response.uKey?.let { is ImageUploadInfo -> response.uKey?.let { uKey ->
Http.postImage( check(Http.postImage(
htcmd = "0x6ff0071", htcmd = "0x6ff0071",
uin = bot.qqAccount, uin = bot.qqAccount,
groupId = GroupId(id), groupId = GroupId(id),
imageInput = image.input, imageInput = image.input,
inputSize = image.inputSize, inputSize = image.inputSize,
uKeyHex = it.toUHexString("") uKeyHex = uKey.toUHexString("").also { require(it.length == 128 * 2) { "Illegal uKey. expected size=256, actual size=${it.length}" } }
) )) { "Group image upload failed: cannot access api" }
} // if null: image already exists logger.verbose("group image uploaded")
} ?: logger.verbose("Group image upload: already exists")
// TODO: 2019/11/17 超过大小的情况 // TODO: 2019/11/17 超过大小的情况
//is Overfile -> throw OverFileSizeMaxException() //is Overfile -> throw OverFileSizeMaxException()
@ -118,6 +119,7 @@ internal class QQImpl @PublishedApi internal constructor(bot: TIMPCBot, override
FriendImagePacket.RequestImageId(qqAccount, sessionKey, id, image).sendAndExpect<FriendImageResponse>().let { FriendImagePacket.RequestImageId(qqAccount, sessionKey, id, image).sendAndExpect<FriendImageResponse>().let {
when (it) { when (it) {
is FriendImageUKey -> { is FriendImageUKey -> {
check(
Http.postImage( Http.postImage(
htcmd = "0x6ff0070", htcmd = "0x6ff0070",
uin = bot.qqAccount, uin = bot.qqAccount,
@ -126,6 +128,8 @@ internal class QQImpl @PublishedApi internal constructor(bot: TIMPCBot, override
imageInput = image.input, imageInput = image.input,
inputSize = image.inputSize inputSize = image.inputSize
) )
) { "Friend image upload failed: cannot access api" }
logger.verbose("friend image uploaded")
it.imageId it.imageId
} }
is FriendImageAlreadyExists -> it.imageId is FriendImageAlreadyExists -> it.imageId