* add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using Elsa.Extensions;
|
|
using Elsa.Telnyx.Client.Models;
|
|
using Elsa.Telnyx.Client.Services;
|
|
using Elsa.Telnyx.Extensions;
|
|
using Elsa.Workflows;
|
|
using Elsa.Workflows.Attributes;
|
|
using Elsa.Workflows.Models;
|
|
using Refit;
|
|
|
|
namespace Elsa.Telnyx.Activities;
|
|
|
|
/// <summary>
|
|
/// Stop audio playback.
|
|
/// </summary>
|
|
[Activity(Constants.Namespace, Description = "Stop audio playback.", Kind = ActivityKind.Task)]
|
|
public abstract class StopAudioPlaybackBase : Activity
|
|
{
|
|
/// <inheritdoc />
|
|
protected StopAudioPlaybackBase(string? source = default, int? line = default) : base(source, line)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Unique identifier and token for controlling the call.
|
|
/// </summary>
|
|
[Input(
|
|
DisplayName = "Call Control ID",
|
|
Description = "Unique identifier and token for controlling the call.",
|
|
Category = "Advanced"
|
|
)]
|
|
public Input<string> CallControlId { get; set; } = default!;
|
|
|
|
/// <summary>
|
|
/// Use 'current' to stop only the current audio or 'all' to stop all audios in the queue.
|
|
/// </summary>
|
|
[Input(
|
|
Description = "Use 'current' to stop only the current audio or 'all' to stop all audios in the queue.",
|
|
DefaultValue = "all",
|
|
Category = "Advanced"
|
|
)]
|
|
public Input<string?> Stop { get; set; } = new("all");
|
|
|
|
/// <inheritdoc />
|
|
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
|
|
{
|
|
var request = new StopAudioPlaybackRequest(Stop.Get(context), context.CreateCorrelatingClientState(context.Id));
|
|
var callControlId = CallControlId.Get(context);
|
|
var telnyxClient = context.GetRequiredService<ITelnyxClient>();
|
|
|
|
try
|
|
{
|
|
await telnyxClient.Calls.StopAudioPlaybackAsync(callControlId, request, context.CancellationToken);
|
|
await HandleDoneAsync(context);
|
|
}
|
|
catch (ApiException e)
|
|
{
|
|
if (!await e.CallIsNoLongerActiveAsync()) throw;
|
|
await HandleDisconnectedAsync(context);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when audio playback is stopping.
|
|
/// </summary>
|
|
protected abstract ValueTask HandleDoneAsync(ActivityExecutionContext context);
|
|
/// <summary>
|
|
/// Called when the call was no longer active.
|
|
/// </summary>
|
|
protected abstract ValueTask HandleDisconnectedAsync(ActivityExecutionContext context);
|
|
} |