Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ public interface ISubscriptionService
{
IAsyncEnumerable<ITryResult<SubscriptionHeader>> ProcessAsync(DomainObjectVersions versions);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Framework.Core;
using Framework.Subscriptions.Domain;

namespace Framework.Subscriptions;

public interface ISyncSubscriptionService
{
List<ITryResult<SubscriptionHeader>> Process(DomainObjectVersions versions);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Anch.Core;

using Framework.Core;
using Framework.Subscriptions.Domain;

namespace Framework.Subscriptions;

public class SyncSubscriptionService(ISubscriptionService subscriptionService, IDefaultCancellationTokenSource? defaultCancellationTokenSource = null) : ISyncSubscriptionService
{
public List<ITryResult<SubscriptionHeader>> Process(DomainObjectVersions versions) =>
defaultCancellationTokenSource.RunSync(async ct => await subscriptionService.ProcessAsync(versions).ToListAsync(ct));
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void AddSubscriptions<TEmployee, TPrincipal>(
services.AddSingleton<ISubscriptionResolver, SubscriptionResolver>();

services.AddScoped<ISubscriptionService, SubscriptionService>();
services.AddScoped<ISyncSubscriptionService, SyncSubscriptionService>();

services.AddSingleton(new EmployeeInfo<TEmployee>(emailPath.ToPropertyAccessors()));
services.AddScoped<IEmployeeEmailExtractor, EmployeeEmailExtractor<TEmployee, TPrincipal>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ await this.AuthManager.For(this.searchNotificationEmployeeLogin2).SetRoleAsync(
this.child_1_1_ManagementUnit), ct);

var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};


var employeeFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(Employee),
ExpandType = NotificationExpandType.DirectOrFirstParent,
Idents = [this.rootEmployee.Id]
};
{
SecurityContextType = typeof(Employee),
ExpandType = NotificationExpandType.DirectOrFirstParent,
Idents = [this.rootEmployee.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter, employeeFilter], ct);
Expand All @@ -120,18 +120,18 @@ public async Task GetPrincipals_Direct_Test2_Missed(CancellationToken ct)
this.child_1_1_ManagementUnit), ct);

var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter], ct);
Expand All @@ -152,24 +152,26 @@ public async Task GetPrincipals_Direct_Test3_Missed(CancellationToken ct)
this.child_1_1_ManagementUnit), ct);

var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};


var employeeChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(Employee), ExpandType = NotificationExpandType.Direct, Idents = [this.rootEmployee.Id]
};
{
SecurityContextType = typeof(Employee),
ExpandType = NotificationExpandType.Direct,
Idents = [this.rootEmployee.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter, employeeChildFilter], ct);
Expand All @@ -192,24 +194,26 @@ public async Task GetPrincipals_Direct_Test4_Searched(CancellationToken ct)


var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};


var employeeChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(Employee), ExpandType = NotificationExpandType.Direct, Idents = [this.rootEmployee.Id]
};
{
SecurityContextType = typeof(Employee),
ExpandType = NotificationExpandType.Direct,
Idents = [this.rootEmployee.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter, employeeChildFilter], ct);
Expand All @@ -235,18 +239,18 @@ public async Task GetPrincipals_DirectOrEmpty_Test1_Searched(CancellationToken c
this.child_1_1_ManagementUnit), ct);

var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter], ct);
Expand Down Expand Up @@ -274,18 +278,18 @@ public async Task GetPrincipals_DirectOrFirstParentOrEmpty_Test1_Searched(Cancel
this.child_1_1_ManagementUnit), ct);

var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter], ct);
Expand All @@ -312,18 +316,18 @@ public async Task GetPrincipals_DirectOrFirstParentOrEmpty_Test2_Searched(Cancel
this.rootManagementUnit), ct);

var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter], ct);
Expand Down Expand Up @@ -353,18 +357,18 @@ public async Task GetPrincipals_DirectOrFirstParentOrEmpty_Test3_Searched(bool s


var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.DirectOrFirstParentOrEmpty,
Idents = [this.child_1_1_ManagementUnit.Id]
};

// Act
var result = swapPriority
Expand Down Expand Up @@ -394,16 +398,18 @@ public async Task GetPrincipals_All_Test1_Searched(CancellationToken ct)


var fbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(BusinessUnit), ExpandType = NotificationExpandType.All, Idents = [this.child_1_1_BusinessUnit.Id]
};
{
SecurityContextType = typeof(BusinessUnit),
ExpandType = NotificationExpandType.All,
Idents = [this.child_1_1_BusinessUnit.Id]
};

var mbuChildFilter = new NotificationFilterGroup<Guid>
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};
{
SecurityContextType = typeof(ManagementUnit),
ExpandType = NotificationExpandType.Direct,
Idents = [this.child_1_1_ManagementUnit.Id]
};

// Act
var result = await this.GetNotificationPrincipalsByRoles([fbuChildFilter, mbuChildFilter], ct);
Expand Down
Loading
Loading