Skip to content

Commit ad4fc22

Browse files
committed
Clean http context in ProcessUserMessageAsync
1 parent cd175b9 commit ad4fc22

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioMessageQueueService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
using BotSharp.Abstraction.Routing;
33
using BotSharp.Core.Infrastructures;
44
using BotSharp.Plugin.Twilio.Models;
5+
using Microsoft.AspNetCore.Http;
56
using Microsoft.Extensions.Hosting;
7+
using System.Security.Claims;
68
using System.Threading;
79
using Task = System.Threading.Tasks.Task;
810

@@ -58,6 +60,11 @@ private async Task ProcessUserMessageAsync(CallerMessage message)
5860
using var scope = _serviceProvider.CreateScope();
5961
var sp = scope.ServiceProvider;
6062

63+
// Clean static HttpContext
64+
var httpContext = sp.GetRequiredService<IHttpContextAccessor>();
65+
httpContext.HttpContext = new DefaultHttpContext();
66+
httpContext.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
67+
6168
AssistantMessage reply = null;
6269
var inputMsg = new RoleDialogModel(AgentRole.User, message.Content);
6370
var conv = sp.GetRequiredService<IConversationService>();

0 commit comments

Comments
 (0)