1
0
mirror of https://github.com/bitwarden/server synced 2026-02-13 06:53:56 +00:00

[PM-25106] Refactor Misleading Stored Procedure/Repository Language (#6890)

* Begin migration to appropriately named sprocs

* Update method and parameter names

* Remove incorrect change

* Changes EF to match collection type comparison

* Adds integration test verifying excluded collections

* Changes EF to match collection type comparison

* Fix whitespacing

* Fix dedented if
This commit is contained in:
sven-bitwarden
2026-02-09 09:25:10 -06:00
committed by GitHub
parent 6548737320
commit 70c01bcfb2
18 changed files with 382 additions and 42 deletions

View File

@@ -350,7 +350,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
}
#nullable enable
public async Task<(OrganizationUserUserDetails? OrganizationUser, ICollection<CollectionAccessSelection> Collections)> GetDetailsByIdWithCollectionsAsync(Guid id)
public async Task<(OrganizationUserUserDetails? OrganizationUser, ICollection<CollectionAccessSelection> Collections)> GetDetailsByIdWithSharedCollectionsAsync(Guid id)
{
var organizationUserUserDetails = await GetDetailsByIdAsync(id);
using (var scope = ServiceScopeFactory.CreateScope())
@@ -359,7 +359,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
var query = from ou in dbContext.OrganizationUsers
join cu in dbContext.CollectionUsers on ou.Id equals cu.OrganizationUserId
join c in dbContext.Collections on cu.CollectionId equals c.Id
where ou.Id == id && c.Type != CollectionType.DefaultUserCollection
where ou.Id == id && c.Type == CollectionType.SharedCollection
select cu;
var collections = await query.Select(cu => new CollectionAccessSelection
{
@@ -438,7 +438,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
}
}
public async Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId, bool includeGroups, bool includeCollections)
public async Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync(Guid organizationId, bool includeGroups, bool includeSharedCollections)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@@ -448,7 +448,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
where ou.OrganizationId == organizationId
select ou).ToListAsync();
if (!includeCollections && !includeGroups)
if (!includeSharedCollections && !includeGroups)
{
return users;
}
@@ -467,12 +467,12 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
.GroupBy(g => g.OrganizationUserId).ToList();
}
if (includeCollections)
if (includeSharedCollections)
{
collections = (await (from cu in dbContext.CollectionUsers
join ou in userIdEntities on cu.OrganizationUserId equals ou.Id
join c in dbContext.Collections on cu.CollectionId equals c.Id
where c.Type != CollectionType.DefaultUserCollection
where c.Type == CollectionType.SharedCollection
select cu).ToListAsync())
.GroupBy(c => c.OrganizationUserId).ToList();
}
@@ -506,7 +506,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
}
public async Task<ICollection<OrganizationUserUserDetails>> GetManyDetailsByOrganizationAsync_vNext(
Guid organizationId, bool includeGroups, bool includeCollections)
Guid organizationId, bool includeGroups, bool includeSharedCollections)
{
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
@@ -541,7 +541,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
? ou.GroupUsers.Select(gu => gu.GroupId).ToList()
: new List<Guid>(),
Collections = includeCollections
Collections = includeSharedCollections
? ou.CollectionUsers
.Where(cu => cu.Collection.Type == CollectionType.SharedCollection)
.Select(cu => new CollectionAccessSelection

View File

@@ -303,7 +303,7 @@ public class CollectionRepository : Repository<Core.Entities.Collection, Collect
}
}
public async Task<ICollection<CollectionAdminDetails>> GetManyByOrganizationIdWithPermissionsAsync(
public async Task<ICollection<CollectionAdminDetails>> GetManySharedByOrganizationIdWithPermissionsAsync(
Guid organizationId, Guid userId, bool includeAccessRelationships)
{
using (var scope = ServiceScopeFactory.CreateScope())

View File

@@ -62,7 +62,7 @@ public class CollectionAdminDetailsQuery : IQuery<CollectionAdminDetails>
{
baseCollectionQuery = baseCollectionQuery.Where(x =>
x.c.OrganizationId == _organizationId &&
x.c.Type != CollectionType.DefaultUserCollection);
x.c.Type == CollectionType.SharedCollection);
}
else if (_collectionId.HasValue)
{