-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OneBot] Implemented mark_msg_as_read Operation
- Loading branch information
1 parent
abe76bc
commit b8926b8
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
Lagrange.OneBot/Core/Operation/Message/MarkMsgAsReadOperation.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,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(); | ||
} | ||
} |