mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
[PM-17777] sponsorships consume seats (#5694)
* Admin initiated sponsorships now use seats similarly to inviting an organization user * Updated f4e endpoint to not expect a user ID, and instead just send a boolean * Fixed failing tests * Updated OrganizationUserReadOccupiedSeatCountByOrganizationIdQuery to ensure both left and right sides are selecting the same columns
This commit is contained in:
@ -14,9 +14,23 @@ public class OrganizationUserReadOccupiedSeatCountByOrganizationIdQuery : IQuery
|
||||
|
||||
public IQueryable<OrganizationUser> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from ou in dbContext.OrganizationUsers
|
||||
where ou.OrganizationId == _organizationId && ou.Status >= OrganizationUserStatusType.Invited
|
||||
select ou;
|
||||
return query;
|
||||
var orgUsersQuery = from ou in dbContext.OrganizationUsers
|
||||
where ou.OrganizationId == _organizationId && ou.Status >= OrganizationUserStatusType.Invited
|
||||
select new OrganizationUser { Id = ou.Id, OrganizationId = ou.OrganizationId, Status = ou.Status };
|
||||
|
||||
// As of https://bitwarden.atlassian.net/browse/PM-17772, a seat is also occupied by a Families for Enterprise sponsorship sent by an
|
||||
// organization admin, even if the user sent the invitation doesn't have a corresponding OrganizationUser in the Enterprise organization.
|
||||
var sponsorshipsQuery = from os in dbContext.OrganizationSponsorships
|
||||
where os.SponsoringOrganizationId == _organizationId &&
|
||||
os.IsAdminInitiated &&
|
||||
!os.ToDelete
|
||||
select new OrganizationUser
|
||||
{
|
||||
Id = os.Id,
|
||||
OrganizationId = _organizationId,
|
||||
Status = OrganizationUserStatusType.Invited
|
||||
};
|
||||
|
||||
return orgUsersQuery.Concat(sponsorshipsQuery);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user