Fix user null issue.
This commit is contained in:
parent
2904c92513
commit
b250fc730d
|
|
@ -8,6 +8,12 @@
|
|||
<PackageIcon>Icon.png</PackageIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Infrastructures\**" />
|
||||
<EmbeddedResource Remove="Infrastructures\**" />
|
||||
<None Remove="Infrastructures\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\arts\Icon.png">
|
||||
<Pack>True</Pack>
|
||||
|
|
@ -22,8 +28,4 @@
|
|||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Infrastructures\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
namespace BotSharp.Abstraction.Utilities;
|
||||
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string IfNullOrEmptyAs(this string str, string defaultValue)
|
||||
=> string.IsNullOrEmpty(str) ? defaultValue : str;
|
||||
}
|
||||
|
|
@ -34,14 +34,25 @@
|
|||
<PackageIconUrl>https://raw.githubusercontent.com/SciSharp/BotSharp/master/docs/static/logos/BotSharp.png</PackageIconUrl>
|
||||
<PackageLicenseUrl>https://raw.githubusercontent.com/SciSharp/BotSharp/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageIcon>Icon.png</PackageIcon>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<NoWarn>1701;1702</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;</DefineConstants>
|
||||
<NoWarn>1701;1702</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<NoWarn>1701;1702</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<NoWarn>1701;1702</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class ConversationController : ControllerBase, IApiAdapter
|
|||
var service = _services.GetRequiredService<IConversationService>();
|
||||
var sess = new Conversation
|
||||
{
|
||||
UserId = _user.Id,
|
||||
AgentId = agentId
|
||||
};
|
||||
sess = await service.NewConversation(sess);
|
||||
|
|
@ -49,7 +50,7 @@ public class ConversationController : ControllerBase, IApiAdapter
|
|||
|
||||
return new MessageResponseModel
|
||||
{
|
||||
Content = result
|
||||
Text = result
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ public class ConversationService : IConversationService
|
|||
var db = _services.GetRequiredService<AgentDbContext>();
|
||||
|
||||
var record = ConversationRecord.FromConversation(sess);
|
||||
record.Id = sess.Id ?? Guid.NewGuid().ToString();
|
||||
record.UserId = sess.UserId ?? _user.Id;
|
||||
record.Id = sess.Id.IfNullOrEmptyAs(Guid.NewGuid().ToString());
|
||||
record.UserId = sess.UserId.IfNullOrEmptyAs(_user.Id);
|
||||
record.Title = "New Conversation";
|
||||
|
||||
db.Transaction<IAgentTable>(delegate
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Core.Conversations.ViewModels;
|
|||
|
||||
public class MessageResponseModel
|
||||
{
|
||||
public string Content { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ global using BotSharp.Abstraction.Agents;
|
|||
global using BotSharp.Abstraction.Conversations;
|
||||
global using BotSharp.Abstraction.Knowledges;
|
||||
global using BotSharp.Abstraction.Users;
|
||||
global using BotSharp.Abstraction.Utilities;
|
||||
global using BotSharp.Core.Repository;
|
||||
global using BotSharp.Core.Repository.Abstraction;
|
||||
global using BotSharp.Core.Repository.DbTables;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ using BotSharp.Plugin.ChatbotUI.ViewModels;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using BotSharp.Abstraction.Conversations;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace BotSharp.Plugin.ChatbotUI.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class ChatbotUiController : ControllerBase, IApiAdapter
|
||||
{
|
||||
|
|
@ -72,7 +74,6 @@ public class ChatbotUiController : ControllerBase, IApiAdapter
|
|||
var sess = new Conversation
|
||||
{
|
||||
Id = input.ConversationId,
|
||||
UserId = Guid.Empty.ToString(),
|
||||
AgentId = input.AgentId
|
||||
};
|
||||
converation = await conversationService.NewConversation(sess);
|
||||
|
|
|
|||
Loading…
Reference in a new issue