Skip to content

Commit

Permalink
Fix race condition between finding bookmarks and indexing workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmskywalker committed Jun 2, 2021
1 parent b6f165c commit 93e80b5
Show file tree
Hide file tree
Showing 32 changed files with 310 additions and 444 deletions.
12 changes: 2 additions & 10 deletions src/activities/Elsa.Activities.Telnyx/Activities/AnswerCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Elsa.Activities.Telnyx.Webhooks.Payloads.Call;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Bookmarks;
using Elsa.Design;
using Elsa.Exceptions;
using Elsa.Expressions;
Expand All @@ -16,24 +15,17 @@
// ReSharper disable once CheckNamespace
namespace Elsa.Activities.Telnyx.Activities
{
public class AnswerCallBookmark : IBookmark
{
}

[Job(
Category = Constants.Category,
Description = "Answer an incoming call. You must issue this command before executing subsequent commands on an incoming call",
Outcomes = new[] { TelnyxOutcomeNames.Pending, TelnyxOutcomeNames.Answered, TelnyxOutcomeNames.CallIsNoLongerActive },
DisplayName = "Answer Call"
)]
public class AnswerCall : EventDrivenActivity<AnswerCallBookmark, CallAnsweredPayload>
public class AnswerCall : Activity
{
private readonly ITelnyxClient _telnyxClient;

public AnswerCall(ITelnyxClient telnyxClient, ICommandSender commandSender, IWorkflowLaunchpad workflowLaunchpad) : base(commandSender, workflowLaunchpad)
{
_telnyxClient = telnyxClient;
}
public AnswerCall(ITelnyxClient telnyxClient) => _telnyxClient = telnyxClient;

[ActivityInput(Label = "Call Control ID", Hint = "Unique identifier and token for controlling the call", Category = PropertyCategories.Advanced, SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string CallControlId { get; set; } = default!;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Elsa.Activities.Telnyx.Webhooks.Payloads.Call;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Bookmarks;
using Elsa.Design;
using Elsa.Exceptions;
using Elsa.Expressions;
Expand All @@ -16,24 +15,17 @@

namespace Elsa.Activities.Telnyx.Activities
{
public class GatherUsingAudioBookmark : IBookmark
{
}

[Action(
[Job(
Category = Constants.Category,
Description = "Play an audio file on the call until the required DTMF signals are gathered to build interactive menus.",
Outcomes = new[] { TelnyxOutcomeNames.Pending, TelnyxOutcomeNames.GatherCompleted, TelnyxOutcomeNames.CallIsNoLongerActive },
DisplayName = "Gather Using Audio"
)]
public class GatherUsingAudio : EventDrivenActivity<GatherUsingAudioBookmark, CallGatherEndedPayload>
public class GatherUsingAudio : Activity
{
private readonly ITelnyxClient _telnyxClient;

public GatherUsingAudio(ITelnyxClient telnyxClient, ICommandSender commandSender, IWorkflowLaunchpad workflowLaunchpad) : base(commandSender, workflowLaunchpad)
{
_telnyxClient = telnyxClient;
}
public GatherUsingAudio(ITelnyxClient telnyxClient) => _telnyxClient = telnyxClient;

[ActivityInput(
Label = "Call Control ID", Hint = "Unique identifier and token for controlling the call",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using Elsa.Activities.Telnyx.Client.Models;
using Elsa.Activities.Telnyx.Client.Services;
using Elsa.Activities.Telnyx.Extensions;
using Elsa.Activities.Telnyx.Providers.Bookmarks;
using Elsa.Activities.Telnyx.Webhooks.Events;
using Elsa.Activities.Telnyx.Webhooks.Payloads.Call;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Bookmarks;
using Elsa.Design;
using Elsa.Exceptions;
using Elsa.Expressions;
Expand All @@ -18,24 +18,17 @@
// ReSharper disable once CheckNamespace
namespace Elsa.Activities.Telnyx.Activities
{
public class GatherUsingSpeakBookmark : IBookmark
{
}

[Action(
Category = Constants.Category,
Description = "Convert text to speech and play it on the call until the required DTMF signals are gathered to build interactive menus.",
Outcomes = new[] { TelnyxOutcomeNames.Pending, TelnyxOutcomeNames.GatherCompleted, TelnyxOutcomeNames.CallIsNoLongerActive },
DisplayName = "Gather Using Speak"
)]
public class GatherUsingSpeak : EventDrivenActivity<GatherUsingSpeakBookmark, CallGatherEndedPayload>
public class GatherUsingSpeak : Activity
{
private readonly ITelnyxClient _telnyxClient;

public GatherUsingSpeak(ITelnyxClient telnyxClient, ICommandSender commandSender, IWorkflowLaunchpad workflowLaunchpad) : base(commandSender, workflowLaunchpad)
{
_telnyxClient = telnyxClient;
}
public GatherUsingSpeak(ITelnyxClient telnyxClient) => _telnyxClient = telnyxClient;

[ActivityInput(
Label = "Call Control ID", Hint = "Unique identifier and token for controlling the call",
Expand Down Expand Up @@ -134,12 +127,6 @@ public GatherUsingSpeak(ITelnyxClient telnyxClient, ICommandSender commandSender
[ActivityOutput(Hint = "The received payload when gathering completed.")]
public CallGatherEndedPayload? ReceivedPayload { get; set; }

public override Task Handle(TelnyxWebhookReceived notification, CancellationToken cancellationToken)
{
// Do nothing. Instead, let the shared CallGatherEndedHandler handle this to avoid sending the same command twice.
return Task.CompletedTask;
}

protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
{
var request = new GatherUsingSpeakRequest(
Expand Down
135 changes: 0 additions & 135 deletions src/activities/Elsa.Activities.Telnyx/Activities/SpeakAndWait.cs

This file was deleted.

14 changes: 3 additions & 11 deletions src/activities/Elsa.Activities.Telnyx/Activities/SpeakText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Elsa.Activities.Telnyx.Webhooks.Payloads.Call;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Bookmarks;
using Elsa.Builders;
using Elsa.Design;
using Elsa.Exceptions;
Expand All @@ -17,23 +16,16 @@

namespace Elsa.Activities.Telnyx.Activities
{
public class SpeakTextBookmark : IBookmark
{
}

[Action(
[Job(
Category = Constants.Category,
Description = "Convert text to speech and play it back on the call.",
Outcomes = new[] { TelnyxOutcomeNames.Speaking, TelnyxOutcomeNames.CallIsNoLongerActive, TelnyxOutcomeNames.FinishedSpeaking },
DisplayName = "Speak Text"
)]
public class SpeakText : EventDrivenActivity<SpeakTextBookmark, CallSpeakEnded>
public class SpeakText : Activity
{
private readonly ITelnyxClient _telnyxClient;
public SpeakText(ITelnyxClient telnyxClient, ICommandSender commandSender, IWorkflowLaunchpad workflowLaunchpad) : base(commandSender, workflowLaunchpad)
{
_telnyxClient = telnyxClient;
}
public SpeakText(ITelnyxClient telnyxClient) => _telnyxClient = telnyxClient;

[ActivityInput(
Label = "Call Control ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Elsa.Activities.Telnyx.Webhooks.Payloads.Call;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Bookmarks;
using Elsa.Design;
using Elsa.Exceptions;
using Elsa.Expressions;
Expand All @@ -15,20 +14,16 @@

namespace Elsa.Activities.Telnyx.Activities
{
public class StartRecordingBookmark : IBookmark
{
}

[Action(
[Job(
Category = Constants.Category,
Description = "Start recording the call.",
Outcomes = new[] {TelnyxOutcomeNames.Recording, TelnyxOutcomeNames.FinishedRecording, TelnyxOutcomeNames.CallIsNoLongerActive, OutcomeNames.Done},
DisplayName = "Start Recording"
)]
public class StartRecording : EventDrivenActivity<StartRecordingBookmark, CallRecordingSaved>
public class StartRecording : Activity
{
private readonly ITelnyxClient _telnyxClient;
public StartRecording(ITelnyxClient telnyxClient, ICommandSender commandSender, IWorkflowLaunchpad workflowLaunchpad) : base(commandSender, workflowLaunchpad) => _telnyxClient = telnyxClient;
public StartRecording(ITelnyxClient telnyxClient) => _telnyxClient = telnyxClient;

[ActivityInput(
Label = "Call Control ID",
Expand Down

0 comments on commit 93e80b5

Please sign in to comment.