mirror of
https://github.com/bitwarden/server
synced 2026-01-14 06:23:46 +00:00
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
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
|
|
);
|
|
}
|
|
}
|
|
}
|