mirror of
https://github.com/bitwarden/server.git
synced 2025-05-10 06:02:24 -05:00

* [PM-17562] Add support for extended properties on event integrations * Clean up IntegrationEventHandlerBase * Respond to PR feedback
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Nodes;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Data.Integrations;
|
|
using Bit.Core.Repositories;
|
|
|
|
#nullable enable
|
|
|
|
namespace Bit.Core.Services;
|
|
|
|
public class SlackEventHandler(
|
|
IUserRepository userRepository,
|
|
IOrganizationRepository organizationRepository,
|
|
IOrganizationIntegrationConfigurationRepository configurationRepository,
|
|
ISlackService slackService)
|
|
: IntegrationEventHandlerBase(userRepository, organizationRepository, configurationRepository)
|
|
{
|
|
protected override IntegrationType GetIntegrationType() => IntegrationType.Slack;
|
|
|
|
protected override async Task ProcessEventIntegrationAsync(JsonObject mergedConfiguration,
|
|
string renderedTemplate)
|
|
{
|
|
var config = mergedConfiguration.Deserialize<SlackIntegrationConfigurationDetails>();
|
|
if (config is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
await slackService.SendSlackMessageByChannelIdAsync(
|
|
config.token,
|
|
renderedTemplate,
|
|
config.channelId
|
|
);
|
|
}
|
|
}
|