Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lagrange.Core/Internal/Context/FlashTransferContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal FlashTransferContext(BotContext botContext)
_url = "https://multimedia.qfile.qq.com/sliceupload";
}

public async Task<bool> UploadFile(string uKey, Stream bodyStream)
public async Task<bool> UploadFile(string uKey, uint appId, Stream bodyStream)
{
var sha1StateVs = new FlashTransferSha1StateV { State = [] };
var chunkCount = (uint)((bodyStream.Length + ChunkSize - 1) / ChunkSize);
Expand Down Expand Up @@ -61,19 +61,19 @@ public async Task<bool> UploadFile(string uKey, Stream bodyStream)
var uploadBuffer = new byte[chunkLength];
await bodyStream.ReadExactlyAsync(uploadBuffer, 0, chunkLength);

var success = await UploadChunk(uKey, (uint)chunkStart, sha1StateVs, uploadBuffer);
var success = await UploadChunk(uKey, appId, (uint)chunkStart, sha1StateVs, uploadBuffer);
if (!success) return false;
}

return true;
}

private async Task<bool> UploadChunk(string uKey, uint start, FlashTransferSha1StateV chunkSha1S, byte[] body)
private async Task<bool> UploadChunk(string uKey, uint appId, uint start, FlashTransferSha1StateV chunkSha1S, byte[] body)
{
var req = new FlashTransferUploadReq
{
FieId1 = 0,
AppId = 1407,
AppId = appId,
FileId3 = 2,
Body = new FlashTransferUploadBody
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Lagrange.Core.Internal.Packets.Service;
internal partial class FlashTransferUploadReq
{
[ProtoMember(1)] public uint FieId1 { get; set; } // 0
[ProtoMember(2)] public uint AppId { get; set; } // 1407
[ProtoMember(2)] public uint AppId { get; set; } // 1402: 私信语音, 1403: 群语音, 1413: 私信视频, 1414: 私信视频封面, 1415: 群视频, 1416: 群视频封面, 1406: 私信图片, 1407: 群聊图片, 14901: 闪传, 14903: 闪传封面
[ProtoMember(3)] public uint FileId3 { get; set; } // 0
[ProtoMember(107)] public FlashTransferUploadBody Body { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions Lagrange.Core/Message/Entities/ImageEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public override async Task Preprocess(BotContext context, BotMessage message)
// Aot 和 MacOS 下使用 FlashTransfer 上传
if (RuntimeFeature.IsDynamicCodeCompiled && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext));
await context.HighwayContext.UploadFile(Stream.Value, IsGroup ? 1004 : 1003, ProtoHelper.Serialize(result.Ext));
Comment thread
Wesley-Young marked this conversation as resolved.
}
else
{
await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value);
await context.FlashTransferContext.UploadFile(result.Ext.UKey, (uint)(IsGroup ? 1407 : 1406), Stream.Value);
}
}
}
Expand Down
Loading