mirror of
https://github.com/bitwarden/server.git
synced 2025-12-12 07:34:55 -06:00
* Use extended cache for caching integration configuration details * Alter strategy to use one cache / database call to retrieve all configurations for an event (including wildcards) * Renamed migration per @withinfocus suggestion
59 lines
2.5 KiB
C#
59 lines
2.5 KiB
C#
using AutoMapper;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Data.Organizations;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
|
using Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries;
|
|
using Bit.Infrastructure.EntityFramework.Repositories;
|
|
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories;
|
|
|
|
public class OrganizationIntegrationConfigurationRepository : Repository<Core.AdminConsole.Entities.OrganizationIntegrationConfiguration, OrganizationIntegrationConfiguration, Guid>, IOrganizationIntegrationConfigurationRepository
|
|
{
|
|
public OrganizationIntegrationConfigurationRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
|
|
: base(serviceScopeFactory, mapper, context => context.OrganizationIntegrationConfigurations)
|
|
{ }
|
|
|
|
public async Task<List<OrganizationIntegrationConfigurationDetails>>
|
|
GetManyByEventTypeOrganizationIdIntegrationType(EventType eventType, Guid organizationId,
|
|
IntegrationType integrationType)
|
|
{
|
|
using (var scope = ServiceScopeFactory.CreateScope())
|
|
{
|
|
var dbContext = GetDatabaseContext(scope);
|
|
var query = new OrganizationIntegrationConfigurationDetailsReadManyByEventTypeOrganizationIdIntegrationTypeQuery(
|
|
organizationId,
|
|
eventType,
|
|
integrationType
|
|
);
|
|
return await query.Run(dbContext).ToListAsync();
|
|
}
|
|
}
|
|
|
|
public async Task<List<OrganizationIntegrationConfigurationDetails>> GetAllConfigurationDetailsAsync()
|
|
{
|
|
using (var scope = ServiceScopeFactory.CreateScope())
|
|
{
|
|
var dbContext = GetDatabaseContext(scope);
|
|
var query = new OrganizationIntegrationConfigurationDetailsReadManyQuery();
|
|
return await query.Run(dbContext).ToListAsync();
|
|
}
|
|
}
|
|
|
|
public async Task<List<Core.AdminConsole.Entities.OrganizationIntegrationConfiguration>> GetManyByIntegrationAsync(
|
|
Guid organizationIntegrationId)
|
|
{
|
|
using (var scope = ServiceScopeFactory.CreateScope())
|
|
{
|
|
var dbContext = GetDatabaseContext(scope);
|
|
var query = new OrganizationIntegrationConfigurationReadManyByOrganizationIntegrationIdQuery(
|
|
organizationIntegrationId
|
|
);
|
|
return await query.Run(dbContext).ToListAsync();
|
|
}
|
|
}
|
|
}
|