Change Service and Event Name

This commit is contained in:
Linwenxuan05 2023-08-27 21:55:59 +08:00
parent 0bf5aa9268
commit 56997cbb8a
3 changed files with 16 additions and 17 deletions

View file

@ -147,11 +147,11 @@ internal class MessagingLogic : LogicBase
case ImageEntity image:
{
string uid = await Collection.Business.CachingLogic.ResolveUid(chain.GroupUin, chain.FriendUin) ?? throw new Exception($"Failed to resolve Uid for Uin {chain.FriendUin}");
var requestTicketEvent = ImageRequestTicketEvent.Create(image.ImageStream, uid);
var requestTicketEvent = ImageUploadEvent.Create(image.ImageStream, uid);
var ticketResults = await Collection.Business.SendEvent(requestTicketEvent);
if (ticketResults.Count != 0)
{
var ticketResult = (ImageRequestTicketEvent)ticketResults[0];
var ticketResult = (ImageUploadEvent)ticketResults[0];
if (!ticketResult.IsExist)
{
bool hwSuccess = await Collection.Highway.UploadSrcByStreamAsync(1, Collection.Keystore.Uin, image.ImageStream, ticketResult.Ticket, requestTicketEvent.FileMd5.UnHex());

View file

@ -1,10 +1,10 @@
using Lagrange.Core.Core.Packets.Message.Element.Implementation;
using Lagrange.Core.Utility.Extension;
#pragma warning disable CS8618
namespace Lagrange.Core.Core.Event.Protocol.Message;
internal class ImageRequestTicketEvent : ProtocolEvent
internal class ImageUploadEvent : ProtocolEvent
{
public Stream Stream { get; }
@ -20,7 +20,7 @@ internal class ImageRequestTicketEvent : ProtocolEvent
public string ServerPath { get; }
private ImageRequestTicketEvent(Stream stream, string targetUid) : base(true)
private ImageUploadEvent(Stream stream, string targetUid) : base(true)
{
Stream = stream;
TargetUid = targetUid;
@ -28,15 +28,15 @@ internal class ImageRequestTicketEvent : ProtocolEvent
FileMd5 = stream.Md5(true);
}
private ImageRequestTicketEvent(int resultCode, string ticket, bool isExist, string serverPath) : base(resultCode)
private ImageUploadEvent(int resultCode, string ticket, bool isExist, string serverPath) : base(resultCode)
{
IsExist = isExist;
Ticket = ticket;
ServerPath = serverPath;
}
public static ImageRequestTicketEvent Create(Stream stream, string targetUid) => new(stream, targetUid);
public static ImageUploadEvent Create(Stream stream, string targetUid) => new(stream, targetUid);
public static ImageRequestTicketEvent Result(int resultCode, string ticket, bool isExist, string imagePath)
public static ImageUploadEvent Result(int resultCode, string ticket, bool isExist, string imagePath)
=> new(resultCode, ticket, isExist, imagePath);
}

View file

@ -2,7 +2,6 @@ using Lagrange.Core.Common;
using Lagrange.Core.Core.Event.Protocol;
using Lagrange.Core.Core.Event.Protocol.Message;
using Lagrange.Core.Core.Packets;
using Lagrange.Core.Core.Packets.Message.Element.Implementation;
using Lagrange.Core.Core.Packets.Service.Highway;
using Lagrange.Core.Core.Service.Abstraction;
using Lagrange.Core.Utility;
@ -12,11 +11,11 @@ using ProtoBuf;
namespace Lagrange.Core.Core.Service.Message;
[EventSubscribe(typeof(ImageRequestTicketEvent))]
[EventSubscribe(typeof(ImageUploadEvent))]
[Service("LongConn.OffPicUp")]
internal class ImageRequestTicketService : BaseService<ImageRequestTicketEvent>
internal class ImageUploadService : BaseService<ImageUploadEvent>
{
protected override bool Build(ImageRequestTicketEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
protected override bool Build(ImageUploadEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
out BinaryPacket output, out List<BinaryPacket>? extraPackets)
{
input.Stream.Seek(0, SeekOrigin.Begin);
@ -69,15 +68,15 @@ internal class ImageRequestTicketService : BaseService<ImageRequestTicketEvent>
}
protected override bool Parse(SsoPacket input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
out ImageRequestTicketEvent output, out List<ProtocolEvent>? extraEvents)
out ImageUploadEvent output, out List<ProtocolEvent>? extraEvents)
{
var payload = input.Payload.ReadBytes(BinaryPacket.Prefix.Uint32 | BinaryPacket.Prefix.WithPrefix);
var packet = Serializer.Deserialize<OffPicUp<OffPicUpResponse>>(payload.AsSpan());
output = ImageRequestTicketEvent.Result((int)(packet.Info?.Result ?? 1),
packet.Info?.UpUkey?.Hex(true) ?? "",
packet.Info?.FileExit ?? false,
packet.Info?.UpResid ?? "");
output = ImageUploadEvent.Result((int)(packet.Info?.Result ?? 1),
packet.Info?.UpUkey?.Hex(true) ?? "",
packet.Info?.FileExit ?? false,
packet.Info?.UpResid ?? "");
extraEvents = null;
return true;
}