mirror of
https://github.com/bitwarden/server
synced 2026-01-16 23:43:22 +00:00
Move all event integration code to Dirt (#6757)
* Move all event integration code to Dirt * Format to fix lint
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using System.Text.Json;
|
||||
using Bit.Core.Dirt.Models.Data.EventIntegrations;
|
||||
using Microsoft.Rest;
|
||||
|
||||
namespace Bit.Core.Dirt.Services.Implementations;
|
||||
|
||||
public class TeamsIntegrationHandler(
|
||||
ITeamsService teamsService)
|
||||
: IntegrationHandlerBase<TeamsIntegrationConfigurationDetails>
|
||||
{
|
||||
public override async Task<IntegrationHandlerResult> HandleAsync(
|
||||
IntegrationMessage<TeamsIntegrationConfigurationDetails> message)
|
||||
{
|
||||
try
|
||||
{
|
||||
await teamsService.SendMessageToChannelAsync(
|
||||
serviceUri: message.Configuration.ServiceUrl,
|
||||
message: message.RenderedTemplate,
|
||||
channelId: message.Configuration.ChannelId
|
||||
);
|
||||
|
||||
return IntegrationHandlerResult.Succeed(message);
|
||||
}
|
||||
catch (HttpOperationException ex)
|
||||
{
|
||||
var category = ClassifyHttpStatusCode(ex.Response.StatusCode);
|
||||
return IntegrationHandlerResult.Fail(
|
||||
message,
|
||||
category,
|
||||
ex.Message
|
||||
);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return IntegrationHandlerResult.Fail(
|
||||
message,
|
||||
IntegrationFailureCategory.ConfigurationError,
|
||||
ex.Message
|
||||
);
|
||||
}
|
||||
catch (UriFormatException ex)
|
||||
{
|
||||
return IntegrationHandlerResult.Fail(
|
||||
message,
|
||||
IntegrationFailureCategory.ConfigurationError,
|
||||
ex.Message
|
||||
);
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
return IntegrationHandlerResult.Fail(
|
||||
message,
|
||||
IntegrationFailureCategory.PermanentFailure,
|
||||
ex.Message
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return IntegrationHandlerResult.Fail(
|
||||
message,
|
||||
IntegrationFailureCategory.TransientError,
|
||||
ex.Message
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user