1
0
mirror of https://github.com/bitwarden/server synced 2025-12-25 12:43:14 +00:00

Fix Organization License Sync (#2864)

This commit is contained in:
Justin Baur
2023-04-24 13:51:08 -04:00
committed by GitHub
parent f961787396
commit a2d45c09ad
32 changed files with 191 additions and 189 deletions

View File

@@ -1,4 +1,6 @@
using AutoMapper;
using Bit.Core.Enums;
using Bit.Core.Models.Data.Organizations;
using Bit.Infrastructure.EntityFramework.Auth.Models;
using Bit.Infrastructure.EntityFramework.Vault.Models;
@@ -24,5 +26,12 @@ public class OrganizationMapperProfile : Profile
public OrganizationMapperProfile()
{
CreateMap<Core.Entities.Organization, Organization>().ReverseMap();
CreateProjection<Organization, SelfHostedOrganizationDetails>()
.ForMember(sd => sd.CollectionCount, opt => opt.MapFrom(o => o.Collections.Count))
.ForMember(sd => sd.GroupCount, opt => opt.MapFrom(o => o.Groups.Count))
.ForMember(sd => sd.OccupiedSeatCount, opt => opt.MapFrom(o => o.OrganizationUsers.Count(ou => ou.Status >= OrganizationUserStatusType.Invited)))
.ForMember(sd => sd.OrganizationUsers, opt => opt.MapFrom(o => o.OrganizationUsers))
.ForMember(sd => sd.ScimConnections, opt => opt.MapFrom(o => o.Connections.Where(c => c.Type == OrganizationConnectionType.Scim)))
.ForMember(sd => sd.SsoConfig, opt => opt.MapFrom(o => o.SsoConfigs.SingleOrDefault()));
}
}