Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using BotSharp.Abstraction.Agents;
using BotSharp.Abstraction.Repositories.Enums;
using BotSharp.Abstraction.Routing.Models;
using BotSharp.Abstraction.Users.Enums;
using Microsoft.EntityFrameworkCore.Metadata;
using System.IO;

namespace BotSharp.Core.Agents.Services;
Expand All @@ -11,7 +13,9 @@ public async Task UpdateAgent(Agent agent, AgentField updateField)
{
var userService = _services.GetRequiredService<IUserService>();
var user = await userService.GetUser(_user.Id);
if (user?.Role != UserRole.Admin) return;
var userAgents = GetAgentsByUser(user?.Id);
var editable = userAgents?.Select(x => x.Id)?.Contains(agent.Id) ?? false;
if (user?.Role != UserRole.Admin && !editable) return;

if (agent == null || string.IsNullOrEmpty(agent.Id)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ join u in Users on ua.UserId equals u.Id

var filter = new AgentFilter
{
IsPublic = true,
AgentIds = agentIds
};
var agents = GetAgents(filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<PagedItems<ConversationViewModel>> GetConversations([FromBody]
user = await userService.GetUser(item.User.Id);
item.User = UserViewModel.FromUser(user);
var agent = await agentService.GetAgent(item.AgentId);
item.AgentName = agent?.Name;
item.AgentName = agent?.Name ?? "Unkown";
}

return new PagedItems<ConversationViewModel>
Expand Down Expand Up @@ -110,7 +110,7 @@ public async Task<IEnumerable<ChatResponseModel>> GetDialogs([FromRoute] string
Data = message.Data,
Sender = new UserViewModel
{
FirstName = agent.Name,
FirstName = agent?.Name ?? "Unkown",
Role = message.Role,
},
RichContent = message.SecondaryRichContent ?? message.RichContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ join u in _dc.Users.AsQueryable() on ua.UserId equals u.Id

var filter = new AgentFilter
{
AgentIds = agentIds,
IsPublic = true
AgentIds = agentIds
};
var agents = GetAgents(filter);
return agents;
Expand Down