Merge pull request #1036 from yileicn/master
optimize ITwilioCallStatusHook
This commit is contained in:
commit
575c148b5e
|
|
@ -12,6 +12,7 @@ public class ConversationFilter
|
|||
public string? AgentId { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? Channel { get; set; }
|
||||
public string? ChannelId { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -430,6 +430,10 @@ public partial class FileRepository
|
|||
{
|
||||
matched = matched && record.Channel == filter.Channel;
|
||||
}
|
||||
if(filter?.ChannelId != null)
|
||||
{
|
||||
matched = matched && record.ChannelId == filter.ChannelId;
|
||||
}
|
||||
if (filter?.UserId != null)
|
||||
{
|
||||
matched = matched && record.UserId == filter.UserId;
|
||||
|
|
|
|||
|
|
@ -371,6 +371,10 @@ public partial class MongoRepository
|
|||
{
|
||||
convFilters.Add(convBuilder.Eq(x => x.Channel, filter.Channel));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter?.ChannelId))
|
||||
{
|
||||
convFilters.Add(convBuilder.Eq(x => x.ChannelId, filter.ChannelId));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(filter?.UserId))
|
||||
{
|
||||
convFilters.Add(convBuilder.Eq(x => x.UserId, filter.UserId));
|
||||
|
|
|
|||
|
|
@ -347,34 +347,52 @@ public class TwilioVoiceController : TwilioController
|
|||
{
|
||||
// voicemail
|
||||
await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
|
||||
async hook => await hook.OnVoicemailLeft(request));
|
||||
async hook =>
|
||||
{
|
||||
if (hook.IsMatch(request)) await hook.OnVoicemailLeft(request);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// phone call completed
|
||||
await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
|
||||
async x => await x.OnUserDisconnected(request));
|
||||
async hook =>
|
||||
{
|
||||
if (hook.IsMatch(request)) await hook.OnUserDisconnected(request);
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (request.CallStatus == "busy")
|
||||
{
|
||||
await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
|
||||
async x => await x.OnCallBusyStatus(request));
|
||||
async hook =>
|
||||
{
|
||||
if (hook.IsMatch(request)) await hook.OnCallBusyStatus(request);
|
||||
});
|
||||
}
|
||||
else if (request.CallStatus == "no-answer")
|
||||
{
|
||||
await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
|
||||
async x => await x.OnCallNoAnswerStatus(request));
|
||||
async hook =>
|
||||
{
|
||||
if (hook.IsMatch(request)) await hook.OnCallNoAnswerStatus(request);
|
||||
});
|
||||
}
|
||||
else if (request.CallStatus == "canceled")
|
||||
{
|
||||
await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
|
||||
async x => await x.OnCallCanceledStatus(request));
|
||||
async hook =>
|
||||
{
|
||||
if (hook.IsMatch(request)) await hook.OnCallCanceledStatus(request);
|
||||
});
|
||||
}
|
||||
else if (request.CallStatus == "failed")
|
||||
{
|
||||
await HookEmitter.Emit<ITwilioCallStatusHook>(_services,
|
||||
async x => await x.OnCallFailedStatus(request));
|
||||
async hook =>
|
||||
{
|
||||
if (hook.IsMatch(request)) await hook.OnCallFailedStatus(request);
|
||||
});
|
||||
}
|
||||
|
||||
return Ok();
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ namespace BotSharp.Plugin.Twilio.Interfaces;
|
|||
|
||||
public interface ITwilioCallStatusHook
|
||||
{
|
||||
Task OnVoicemailLeft(ConversationalVoiceRequest request);
|
||||
Task OnUserDisconnected(ConversationalVoiceRequest request);
|
||||
Task OnRecordingCompleted(ConversationalVoiceRequest request);
|
||||
Task OnVoicemailStarting(ConversationalVoiceRequest request);
|
||||
bool IsMatch(ConversationalVoiceRequest request) => true;
|
||||
Task OnVoicemailLeft(ConversationalVoiceRequest request) => Task.CompletedTask;
|
||||
Task OnUserDisconnected(ConversationalVoiceRequest request) => Task.CompletedTask;
|
||||
Task OnRecordingCompleted(ConversationalVoiceRequest request) => Task.CompletedTask;
|
||||
Task OnVoicemailStarting(ConversationalVoiceRequest request)=> Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// 1. The recipient's phone line is already engaged.
|
||||
|
|
@ -17,11 +18,11 @@ public interface ITwilioCallStatusHook
|
|||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task OnCallBusyStatus(ConversationalVoiceRequest request);
|
||||
Task OnCallBusyStatus(ConversationalVoiceRequest request)=> Task.CompletedTask;
|
||||
|
||||
Task OnCallNoAnswerStatus(ConversationalVoiceRequest request);
|
||||
Task OnCallNoAnswerStatus(ConversationalVoiceRequest request) => Task.CompletedTask;
|
||||
|
||||
Task OnCallCanceledStatus(ConversationalVoiceRequest request);
|
||||
Task OnCallCanceledStatus(ConversationalVoiceRequest request)=> Task.CompletedTask;
|
||||
|
||||
Task OnCallFailedStatus(ConversationalVoiceRequest request);
|
||||
Task OnCallFailedStatus(ConversationalVoiceRequest request)=> Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue