diff --git a/src/Core/AdminConsole/Models/Data/Organizations/OrganizationIntegrationConfigurationDetails.cs b/src/Core/AdminConsole/Models/Data/Organizations/OrganizationIntegrationConfigurationDetails.cs new file mode 100644 index 0000000000..e00387fcf7 --- /dev/null +++ b/src/Core/AdminConsole/Models/Data/Organizations/OrganizationIntegrationConfigurationDetails.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Nodes; +using Bit.Core.Enums; + +#nullable enable + +namespace Bit.Core.Models.Data.Organizations; + +public class OrganizationIntegrationConfigurationDetails +{ + public Guid Id { get; set; } + public Guid OrganizationIntegrationId { get; set; } + public IntegrationType IntegrationType { get; set; } + public EventType EventType { get; set; } + public string? Configuration { get; set; } + public string? IntegrationConfiguration { get; set; } + public string? Template { get; set; } + + public JsonObject MergedConfiguration + { + get + { + var configJson = JsonNode.Parse(Configuration ?? string.Empty) as JsonObject ?? new JsonObject(); + var integrationJson = JsonNode.Parse(IntegrationConfiguration ?? string.Empty) as JsonObject ?? new JsonObject(); + + foreach (var kvp in configJson) + { + integrationJson[kvp.Key] = kvp.Value; + } + + return integrationJson; + } + } +} diff --git a/src/Core/AdminConsole/Repositories/IOrganizationIntegrationConfigurationRepository.cs b/src/Core/AdminConsole/Repositories/IOrganizationIntegrationConfigurationRepository.cs index 487d2ea12c..3d1cb7b952 100644 --- a/src/Core/AdminConsole/Repositories/IOrganizationIntegrationConfigurationRepository.cs +++ b/src/Core/AdminConsole/Repositories/IOrganizationIntegrationConfigurationRepository.cs @@ -1,11 +1,12 @@ using Bit.Core.AdminConsole.Entities; using Bit.Core.Enums; +using Bit.Core.Models.Data.Organizations; namespace Bit.Core.Repositories; public interface IOrganizationIntegrationConfigurationRepository : IRepository { - Task> GetConfigurationsAsync( + Task> GetConfigurationsAsync( Guid organizationId, IntegrationType integrationType, EventType eventType); diff --git a/src/Infrastructure.Dapper/AdminConsole/Repositories/OrganizationIntegrationConfigurationRepository.cs b/src/Infrastructure.Dapper/AdminConsole/Repositories/OrganizationIntegrationConfigurationRepository.cs index 3d5953d240..1896b8ea3f 100644 --- a/src/Infrastructure.Dapper/AdminConsole/Repositories/OrganizationIntegrationConfigurationRepository.cs +++ b/src/Infrastructure.Dapper/AdminConsole/Repositories/OrganizationIntegrationConfigurationRepository.cs @@ -1,6 +1,7 @@ using System.Data; using Bit.Core.AdminConsole.Entities; using Bit.Core.Enums; +using Bit.Core.Models.Data.Organizations; using Bit.Core.Repositories; using Bit.Core.Settings; using Bit.Infrastructure.Dapper.Repositories; @@ -19,15 +20,15 @@ public class OrganizationIntegrationConfigurationRepository : Repository> GetConfigurationsAsync( + public async Task> GetConfigurationsAsync( Guid organizationId, IntegrationType integrationType, EventType eventType) { using (var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( - "[dbo].[OrganizationIntegrationConfiguration_ReadManyByEventTypeOrganizationIdIntegrationType]", + var results = await connection.QueryAsync( + "[dbo].[OrganizationIntegrationConfigurationDetails_ReadManyByEventTypeOrganizationIdIntegrationType]", new { EventType = eventType,