-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] Fetch the filtered requests simultaneously in FetchGroupReques…
…ts (#571)
- Loading branch information
Showing
5 changed files
with
82 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0x10C0_2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
/// <summary> | ||
/// Fetch Friends & Group Notification filtered List | ||
/// </summary> | ||
[ProtoContract] | ||
[OidbSvcTrpcTcp(0x10c0, 2)] | ||
internal class OidbSvcTrpcTcp0x10C0_2 | ||
{ | ||
[ProtoMember(1)] public uint Count { get; set; } // 20 | ||
|
||
[ProtoMember(2)] public uint Field2 { get; set; } // 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Lagrange.Core/Internal/Service/System/FetchFilteredGroupRequestsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Internal.Event; | ||
using Lagrange.Core.Internal.Event.System; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Response; | ||
using Lagrange.Core.Utility.Extension; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.System; | ||
|
||
[EventSubscribe(typeof(FetchGroupRequestsEvent))] | ||
[Service("OidbSvcTrpcTcp.0x10c0_2")] | ||
internal class FetchFilteredGroupRequestsService : BaseService<FetchGroupRequestsEvent> | ||
{ | ||
protected override bool Build(FetchGroupRequestsEvent input, BotKeystore keystore, BotAppInfo appInfo, | ||
BotDeviceInfo device, out Span<byte> output, out List<Memory<byte>>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x10C0_2>(new OidbSvcTrpcTcp0x10C0_2 | ||
{ | ||
Count = 20, | ||
Field2 = 0 | ||
}); | ||
|
||
output = packet.Serialize(); | ||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, out FetchGroupRequestsEvent output, | ||
out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var payload = Serializer.Deserialize<OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x10C0Response>>(input); | ||
var events = payload.Body.Requests?.Select(x => new FetchGroupRequestsEvent.RawEvent( | ||
x.Group.GroupUin, | ||
x.Invitor?.Uid, | ||
x.Invitor?.Name, | ||
x.Target.Uid, | ||
x.Target.Name, | ||
x.Operator?.Uid, | ||
x.Operator?.Name, | ||
x.Sequence, | ||
x.State, | ||
x.EventType, | ||
x.Comment | ||
)).ToList() ?? new List<FetchGroupRequestsEvent.RawEvent>(); | ||
|
||
output = FetchGroupRequestsEvent.Result((int)payload.ErrorCode, events); | ||
extraEvents = null; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters