1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-17 07:30:59 -05:00

[PM-22442] Remove CollectionService (#6015)

* Refactor Collections and OrganizationExport Controllers to Remove ICollectionService Dependency

* Remove ICollectionService registration from ServiceCollectionExtensions

* Remove CollectionServiceTests file as part of the ongoing refactor to eliminate ICollectionService.

* Remove ICollectionService and its implementation in CollectionService as part of the ongoing refactor to eliminate the service.
This commit is contained in:
Rui Tomé
2025-07-01 13:17:53 +01:00
committed by GitHub
parent 20bf1455cf
commit e8ad23c8bc
6 changed files with 0 additions and 125 deletions

View File

@ -1,8 +0,0 @@
using Bit.Core.Entities;
namespace Bit.Core.Services;
public interface ICollectionService
{
Task DeleteUserAsync(Collection collection, Guid organizationUserId);
}

View File

@ -1,40 +0,0 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
namespace Bit.Core.Services;
public class CollectionService : ICollectionService
{
private readonly IEventService _eventService;
private readonly IOrganizationUserRepository _organizationUserRepository;
private readonly ICollectionRepository _collectionRepository;
public CollectionService(
IEventService eventService,
IOrganizationUserRepository organizationUserRepository,
ICollectionRepository collectionRepository)
{
_eventService = eventService;
_organizationUserRepository = organizationUserRepository;
_collectionRepository = collectionRepository;
}
public async Task DeleteUserAsync(Collection collection, Guid organizationUserId)
{
if (collection.Type == Enums.CollectionType.DefaultUserCollection)
{
throw new BadRequestException("You cannot modify member access for collections with the type as DefaultUserCollection.");
}
var orgUser = await _organizationUserRepository.GetByIdAsync(organizationUserId);
if (orgUser == null || orgUser.OrganizationId != collection.OrganizationId)
{
throw new NotFoundException();
}
await _collectionRepository.DeleteUserAsync(collection.Id, organizationUserId);
await _eventService.LogOrganizationUserEventAsync(orgUser, Enums.EventType.OrganizationUser_Updated);
}
}