mirror of
https://github.com/bitwarden/server
synced 2026-01-17 07:53:36 +00:00
* Add CQRS and caching support for OrganizationIntegrations * Use primary constructor for Delete command, per Claude suggestion * Fix namespace * Add XMLDoc for new commands / queries * Remove unnecessary extra call to AddExtendedCache in Startup (call in EventIntegrationsServiceCollectionExtensions handles this instead) * Alter strategy to use one cache / database call to retrieve all configurations for an event (including wildcards) * Updated README documentation to reflect updated Caching doc and updated CQRS approach
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using Bit.Core.AdminConsole.EventIntegrations.OrganizationIntegrations.Interfaces;
|
|
using Bit.Core.Exceptions;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Core.Utilities;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using ZiggyCreatures.Caching.Fusion;
|
|
|
|
namespace Bit.Core.AdminConsole.EventIntegrations.OrganizationIntegrations;
|
|
|
|
/// <summary>
|
|
/// Command implementation for deleting organization integrations with cache invalidation support.
|
|
/// </summary>
|
|
public class DeleteOrganizationIntegrationCommand(
|
|
IOrganizationIntegrationRepository integrationRepository,
|
|
[FromKeyedServices(EventIntegrationsCacheConstants.CacheName)] IFusionCache cache)
|
|
: IDeleteOrganizationIntegrationCommand
|
|
{
|
|
public async Task DeleteAsync(Guid organizationId, Guid integrationId)
|
|
{
|
|
var integration = await integrationRepository.GetByIdAsync(integrationId);
|
|
if (integration is null || integration.OrganizationId != organizationId)
|
|
{
|
|
throw new NotFoundException();
|
|
}
|
|
|
|
await integrationRepository.DeleteAsync(integration);
|
|
await cache.RemoveByTagAsync(
|
|
EventIntegrationsCacheConstants.BuildCacheTagForOrganizationIntegration(
|
|
organizationId: organizationId,
|
|
integrationType: integration.Type
|
|
));
|
|
}
|
|
}
|