about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--MatrixAntiDmSpam.Core/InviteManager.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/MatrixAntiDmSpam.Core/InviteManager.cs b/MatrixAntiDmSpam.Core/InviteManager.cs

index 12fdc5c..e8a5dc1 100644 --- a/MatrixAntiDmSpam.Core/InviteManager.cs +++ b/MatrixAntiDmSpam.Core/InviteManager.cs
@@ -21,6 +21,8 @@ public class InviteManager( AuthenticatedHomeserverGeneric homeserver) : IHostedService { private readonly GenericRoom? _logRoom = string.IsNullOrWhiteSpace(config.LogRoom) ? null : homeserver.GetRoom(config.LogRoom); public List<Func<RoomInviteContext, StateEventResponse, Task>> OnInviteRejected { get; } = []; + public List<Func<RoomInviteContext, StateEventResponse, Task>> OnBeforeInviteRejected { get; } = []; + public async Task StartAsync(CancellationToken cancellationToken) { roomInviteHandler.OnInviteReceived.Add(CheckPoliciesAgainstInvite); @@ -88,6 +90,10 @@ public class InviteManager( var policyRoom = config.PolicyLists.First(x => x.RoomId == policyEvent.RoomId); logger.LogWarning("[{}] Rejecting invite to {}, matching {} in {}: {}", homeserver.WhoAmI.UserId, invite.RoomId, policy.GetType().GetFriendlyName(), policyRoom.Name, policy.ToJson(ignoreNull: true)); + + foreach (var callback in OnBeforeInviteRejected) { + await callback(invite, policyEvent); + } if (_logRoom is not null) { var roomName = await invite.TryGetRoomNameAsync();