Skip to content

Commit

Permalink
[OneBot] Implemented mark_msg_as_read Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Mar 2, 2024
1 parent abe76bc commit b8926b8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Lagrange.OneBot/Core/Operation/Message/MarkMsgAsReadOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Lagrange.Core;
using Lagrange.Core.Common.Interface.Api;
using Lagrange.Core.Message;
using Lagrange.OneBot.Core.Entity.Action;
using Lagrange.OneBot.Core.Operation.Converters;
using Lagrange.OneBot.Database;
using LiteDB;

namespace Lagrange.OneBot.Core.Operation.Message;

[Operation("mark_msg_as_read")]
internal class MarkMsgAsReadOperation(LiteDatabase database) : IOperation
{
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload)
{
if (payload.Deserialize<OneBotGetMessage>(SerializerOptions.DefaultOptions) is { } getMsg)
{
var record = database.GetCollection<MessageRecord>().FindOne(x => x.MessageHash == getMsg.MessageId);
var chain = (MessageChain)record;
await context.MarkAsRead(chain);
}

throw new Exception();
}
}

0 comments on commit b8926b8

Please sign in to comment.