Skip to content

Commit

Permalink
[OneBot] temporary resolution of memory leaks (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishkong authored Aug 20, 2024
1 parent 8f4c6e2 commit 8b56d09
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions Lagrange.OneBot/Core/Notify/NotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
using Lagrange.OneBot.Core.Entity.Notify;
using Lagrange.OneBot.Core.Network;
using Lagrange.OneBot.Database;
using LiteDB;
using Microsoft.Extensions.Logging;

namespace Lagrange.OneBot.Core.Notify;

public sealed class NotifyService(BotContext bot, ILogger<NotifyService> logger, LiteDatabase database, LagrangeWebSvcCollection service)
public sealed class NotifyService(BotContext bot, ILogger<NotifyService> logger, LagrangeWebSvcCollection service)
{
public void RegisterEvents()
{
Expand Down Expand Up @@ -196,22 +195,10 @@ await service.SendJsonAsync(new OneBotGroupEssence(bot.BotUin)
{
logger.LogInformation(@event.ToString());

var record = database
.GetCollection<MessageRecord>()
.FindOne(Query.And(
Query.EQ("GroupUin", new BsonValue(@event.TargetGroupUin)),
Query.EQ("Sequence", new BsonValue(@event.TargetSequence))
));

if (record == null)
{
logger.LogWarning("No message record found for GroupUin: {GroupUin}, Sequence: {Sequence}", @event.TargetGroupUin, @event.TargetSequence);
}

await service.SendJsonAsync(new OneBotGroupReaction(
bot.BotUin,
@event.TargetGroupUin,
record?.MessageHash ?? 0,
0,
@event.OperatorUin,
@event.IsAdd ? "add" : "remove",
@event.Code,
Expand Down

0 comments on commit 8b56d09

Please sign in to comment.