1 files changed, 31 insertions, 0 deletions
diff --git a/MatrixAntiDmSpam.Core/ReportManager.cs b/MatrixAntiDmSpam.Core/ReportManager.cs
new file mode 100644
index 0000000..46f0666
--- /dev/null
+++ b/MatrixAntiDmSpam.Core/ReportManager.cs
@@ -0,0 +1,31 @@
+using LibMatrix;
+using LibMatrix.Helpers;
+using LibMatrix.Homeservers;
+using LibMatrix.RoomTypes;
+using LibMatrix.Utilities.Bot.Interfaces;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace MatrixAntiDmSpam.Core;
+
+public class ReportManager(
+ ILogger<ReportManager> logger,
+ AntiDmSpamConfiguration config,
+ InviteManager inviteManager,
+ AuthenticatedHomeserverGeneric homeserver) : IHostedService {
+ private readonly GenericRoom? _logRoom = string.IsNullOrWhiteSpace(config.LogRoom) ? null : homeserver.GetRoom(config.LogRoom);
+
+ public async Task StartAsync(CancellationToken cancellationToken) {
+ if (config.ReportBlockedInvites) {
+ inviteManager.OnInviteRejected.Add(ReportRejectedInvite);
+ }
+ }
+
+ public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
+
+ private async Task ReportRejectedInvite(RoomInviteContext invite, StateEventResponse policyEvent) {
+ logger.LogInformation("ReportRejectedInvite not implemented");
+ var msgTask = _logRoom?.SendMessageEventAsync(new MessageBuilder().WithBody("meow").Build());
+ if (msgTask is not null) await msgTask;
+ }
+}
\ No newline at end of file
|