From c79b98cb68771b619cdb9f658d32ad3e9691a592 Mon Sep 17 00:00:00 2001 From: Linwenxuan <116782992+Linwenxuan05@users.noreply.github.com> Date: Sat, 28 Oct 2023 18:22:46 +0800 Subject: [PATCH] [Core] Highway read Uin from ContextCollection --- Lagrange.Core/Internal/Context/HighwayContext.cs | 6 +++--- .../Internal/Context/Logic/Implementation/MessagingLogic.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lagrange.Core/Internal/Context/HighwayContext.cs b/Lagrange.Core/Internal/Context/HighwayContext.cs index dd91543cc..1e0fb5359 100644 --- a/Lagrange.Core/Internal/Context/HighwayContext.cs +++ b/Lagrange.Core/Internal/Context/HighwayContext.cs @@ -67,11 +67,11 @@ public async Task EchoAsync(uint uin) } } - public async Task UploadSrcByStreamAsync(int commonId, uint uin, Stream data, string ticket, byte[] md5, byte[]? extendInfo = null) + public async Task UploadSrcByStreamAsync(int commonId, Stream data, string ticket, byte[] md5, byte[]? extendInfo = null) { bool success = true; var upBlocks = new List(); - var uri = new Uri($"http://htdata3.qq.com:80/cgi-bin/httpconn?htcmd=0x6FF0087&uin={uin}"); + var uri = new Uri($"http://htdata3.qq.com:80/cgi-bin/httpconn?htcmd=0x6FF0087&uin={Collection.Keystore.Uin}"); long fileSize = data.Length; int offset = 0; @@ -83,7 +83,7 @@ public async Task UploadSrcByStreamAsync(int commonId, uint uin, Stream da { var buffer = new byte[Math.Min(chunkSize, fileSize - offset)]; int payload = await data.ReadAsync(buffer.AsMemory()); - var reqBody = new UpBlock(commonId, uin, Interlocked.Increment(ref _sequence), (ulong)fileSize, (ulong)offset, ticket, md5, buffer, extendInfo); + var reqBody = new UpBlock(commonId, Collection.Keystore.Uin, Interlocked.Increment(ref _sequence), (ulong)fileSize, (ulong)offset, ticket, md5, buffer, extendInfo); upBlocks.Add(reqBody); offset += payload; diff --git a/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs b/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs index 5aef41183..2280576b0 100644 --- a/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs +++ b/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs @@ -187,7 +187,7 @@ private async Task UploadResources(MessageChain chain) var ticketResult = (ImageUploadEvent)results[0]; if (!ticketResult.IsExist) { - bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(1, Collection.Keystore.Uin, image.ImageStream, ticketResult.Ticket, @event.FileMd5.UnHex()); + bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(1, image.ImageStream, ticketResult.Ticket, @event.FileMd5.UnHex()); if (!hwSuccess) { Collection.Log.LogFatal(Tag, "Failed to upload image to highway"); @@ -208,7 +208,7 @@ private async Task UploadResources(MessageChain chain) var ticketResult = (ImageGroupUploadEvent)results[0]; if (!ticketResult.IsExist) { - bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(2, Collection.Keystore.Uin, image.ImageStream, ticketResult.Ticket, @event.FileMd5.UnHex()); + bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(2, image.ImageStream, ticketResult.Ticket, @event.FileMd5.UnHex()); if (!hwSuccess) { Collection.Log.LogFatal(Tag, "Failed to upload image to highway");