feat: add MaxSubs enforcement, delivery-time deny filtering, auto-unsub cleanup
This commit is contained in:
@@ -45,8 +45,18 @@ public sealed class ClientPermissions : IDisposable
|
||||
{
|
||||
if (_subscribe == null)
|
||||
return true;
|
||||
if (!_subscribe.IsAllowed(subject))
|
||||
return false;
|
||||
if (queue != null && _subscribe.IsDenied(queue))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return _subscribe.IsAllowed(subject);
|
||||
public bool IsDeliveryAllowed(string subject)
|
||||
{
|
||||
if (_subscribe == null)
|
||||
return true;
|
||||
return _subscribe.IsDeliveryAllowed(subject);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -117,6 +127,21 @@ public sealed class PermissionSet : IDisposable
|
||||
return allowed;
|
||||
}
|
||||
|
||||
public bool IsDenied(string subject)
|
||||
{
|
||||
if (_deny == null) return false;
|
||||
var result = _deny.Match(subject);
|
||||
return result.PlainSubs.Length > 0 || result.QueueSubs.Length > 0;
|
||||
}
|
||||
|
||||
public bool IsDeliveryAllowed(string subject)
|
||||
{
|
||||
if (_deny == null)
|
||||
return true;
|
||||
var result = _deny.Match(subject);
|
||||
return result.PlainSubs.Length == 0 && result.QueueSubs.Length == 0;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_allow?.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user