about summary refs log tree commit diff
path: root/MatrixAntiDmSpam.Core/ReportManager.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-05-22 17:20:42 +0200
committerRory& <root@rory.gay>2025-05-22 17:20:42 +0200
commit516db6f00a346d3813541b00471b9e548a9a4460 (patch)
treeaac46874756a86ad011e2e10ae271424f2f5b4d6 /MatrixAntiDmSpam.Core/ReportManager.cs
parentMove logging to the end of sample config (diff)
downloadMatrixAntiDmSpam-516db6f00a346d3813541b00471b9e548a9a4460.tar.xz
Split up the different features in separate classes
Diffstat (limited to 'MatrixAntiDmSpam.Core/ReportManager.cs')
-rw-r--r--MatrixAntiDmSpam.Core/ReportManager.cs31
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