blob: 46f06664c8a9bd2245f842878b13b9987e24a2cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}
}
|