Skip to content

Commit f07ca8b

Browse files
committed
[Core] Expose fileId for GroupFSUpload
1 parent 9915dd7 commit f07ca8b

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Lagrange.Core/Common/Interface/MessageExt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static Task<List<BotMessage>> GetRoamMessage(this BotContext context, Bot
2727
public static Task<bool> SendFriendFile(this BotContext context, long targetUin, Stream fileStream, string? fileName = null)
2828
=> context.EventContext.GetLogic<OperationLogic>().SendFriendFile(targetUin, fileStream, fileName);
2929

30-
public static Task<bool> SendGroupFile(this BotContext context, long groupUin, Stream fileStream, string? fileName = null, string parentDirectory = "/")
30+
public static Task<string> SendGroupFile(this BotContext context, long groupUin, Stream fileStream, string? fileName = null, string parentDirectory = "/")
3131
=> context.EventContext.GetLogic<OperationLogic>().SendGroupFile(groupUin, fileStream, fileName, parentDirectory);
3232

3333
public static Task<string> GroupFSDownload(this BotContext context, long groupUin, string fileId)

Lagrange.Core/Internal/Logic/OperationLogic.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private static string ResolveFileName(Stream fileStream, string? fileName)
124124
return fileName;
125125
}
126126

127-
public async Task<bool> SendGroupFile(long groupUin, Stream fileStream, string? fileName, string parentDirectory)
127+
public async Task<string> SendGroupFile(long groupUin, Stream fileStream, string? fileName, string parentDirectory)
128128
{
129129
fileName = ResolveFileName(fileStream, fileName);
130130

@@ -185,13 +185,13 @@ public async Task<bool> SendGroupFile(long groupUin, Stream fileStream, string?
185185
};
186186

187187
bool success = await context.HighwayContext.UploadFile(fileStream, 71, ProtoHelper.Serialize(ext));
188-
if (!success) return false;
188+
if (!success) throw new OperationException(-1, "File upload failed");
189189
}
190190

191191
uint random = (uint)Random.Shared.Next();
192192
var feedResult = await context.EventContext.SendEvent<GroupFileSendEventResp>(new GroupFileSendEventReq(groupUin, uploadResp.FileId, random));
193193
if (feedResult.RetCode != 0) throw new OperationException(feedResult.RetCode, feedResult.RetMsg);
194194

195-
return true; // TODO: Random
195+
return uploadResp.FileId;
196196
}
197197
}

0 commit comments

Comments
 (0)