Skip to content

Commit

Permalink
[Core] Highway read Uin from ContextCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 28, 2023
1 parent 8ca7f25 commit c79b98c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Lagrange.Core/Internal/Context/HighwayContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public async Task<bool> EchoAsync(uint uin)
}
}

public async Task<bool> UploadSrcByStreamAsync(int commonId, uint uin, Stream data, string ticket, byte[] md5, byte[]? extendInfo = null)
public async Task<bool> UploadSrcByStreamAsync(int commonId, Stream data, string ticket, byte[] md5, byte[]? extendInfo = null)
{
bool success = true;
var upBlocks = new List<UpBlock>();
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;
Expand All @@ -83,7 +83,7 @@ public async Task<bool> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit c79b98c

Please sign in to comment.