diff --git a/BeWo/Styles/Features/AIChatStyles.xaml b/BeWo/Styles/Features/AIChatStyles.xaml
index 698a2f91b..773209dd2 100644
--- a/BeWo/Styles/Features/AIChatStyles.xaml
+++ b/BeWo/Styles/Features/AIChatStyles.xaml
@@ -157,7 +157,7 @@
Background="#15000000"
BorderBrush="Black"
BorderThickness="0"
- CornerRadius="20, 20, 20, 20">
+ CornerRadius="15, 15, 15, 15">
diff --git a/Data/Entities/AiConversation.cs b/Data/Entities/AiConversation.cs
index 98e4c8e39..5a0e63a3b 100644
--- a/Data/Entities/AiConversation.cs
+++ b/Data/Entities/AiConversation.cs
@@ -21,6 +21,7 @@ namespace BeWo.Data.Entities
public virtual DateTime Updated { get; set; }
public virtual AiModel Modell { get; set; }
public virtual string Context { get; set; }
+ public virtual long? ApplicationUserOid { get; set; }
public virtual IList ContextBeWoObjects { get; set; }
public virtual int UIContext { get; set; }
public virtual IList Messages { get; set; }
diff --git a/Data/Mappings/AiConversation.hbm.xml b/Data/Mappings/AiConversation.hbm.xml
index 05d3348bd..8cb81d761 100644
--- a/Data/Mappings/AiConversation.hbm.xml
+++ b/Data/Mappings/AiConversation.hbm.xml
@@ -4,6 +4,7 @@
+
@@ -17,6 +18,8 @@
+
+
+
diff --git a/Data/Security/UserRightHelper.cs b/Data/Security/UserRightHelper.cs
index 097594b2d..07c9f225f 100644
--- a/Data/Security/UserRightHelper.cs
+++ b/Data/Security/UserRightHelper.cs
@@ -14,7 +14,16 @@ namespace BeWo.Data.Security
{
public static readonly string BASE_VERSION = "1.0";
- public static ApplicationUser GetLoggedInUser()
+ public static ApplicationUser GetLoggedInUserWithOid()
+ {
+ if(GetLoggedInUser() is ApplicationUser user && user.Oid is long)
+ return user;
+
+ throw new InvalidOperationException("RequireLoggedInUserOid");
+ }
+
+
+ public static ApplicationUser GetLoggedInUser()
{
return LoggedInUserOperationContextExt.Current?.User ?? SessionFacade.LoggedInUser;
diff --git a/Model/Changes_2025_04_01 AI Feature.txt b/Model/Changes_2025_04_01 AI Feature.txt
index 1c84ba07e..c2870311c 100644
--- a/Model/Changes_2025_04_01 AI Feature.txt
+++ b/Model/Changes_2025_04_01 AI Feature.txt
@@ -29,8 +29,10 @@ CREATE TABLE `AiConversation` (
`Model` bigint NOT NULL,
`Context` varchar(256),
`UIContext` int,
+`ApplicationUserOid` bigint DEFAULT NULL,
PRIMARY KEY (`Oid`),
-CONSTRAINT `FK_AICONVERSATION_AIMODELL_OID` FOREIGN KEY (`Model`) REFERENCES `aimodel` (`Oid`)
+CONSTRAINT `FK_AICONVERSATION_AIMODELL_OID` FOREIGN KEY (`Model`) REFERENCES `aimodel` (`Oid`) ON DELETE CASCADE ON UPDATE CASCADE,
+CONSTRAINT `FK_AICONVERSATION_APPLICATIONUSER_OID` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `4000000000`.`applicationuser` (`Oid`) ON DELETE SET NULL ON UPDATE CASCADE;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
CREATE TABLE `AiConversationMessage` (
diff --git a/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs b/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs
index ce0f58fe6..6d362f38c 100644
--- a/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs
+++ b/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs
@@ -1,5 +1,7 @@
-using BeWo.Data.Access;
+using BeWo.Data;
+using BeWo.Data.Access;
using BeWo.Data.Entities;
+using BeWo.Data.Security;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy;
@@ -67,8 +69,9 @@ namespace BeWo.Service.ServiceImplementations
public IEnumerable GetAiConversations(int uicontext)
{
// SearchDAO
+ var current_user = UserRightHelper.GetLoggedInUserWithOid();
var convs = DAOFactory.GenericDAO.GetAll();
- var filter = convs.Where(x => x.UIContext == uicontext);
+ var filter = convs.Where(x => x.UIContext == uicontext && x.ApplicationUserOid == current_user.Oid);
var dcs = MapperFactory.AiConversation.MapToNewDCs(filter);
return dcs;
@@ -76,6 +79,8 @@ namespace BeWo.Service.ServiceImplementations
public AiConversationDC CreateAiConversation(int uicontext, long model, List> bewoobjects)
{
+ var current_user = UserRightHelper.GetLoggedInUserWithOid();
+
var system = AiSystemBuilder.CreateSystemInstructions(uicontext, bewoobjects);
var conv = new AiConversation();
@@ -85,6 +90,7 @@ namespace BeWo.Service.ServiceImplementations
conv.Modell = DAOFactory.GenericDAO.LoadByID(model);
conv.UIContext = uicontext;
conv.Updated = DateTime.Now;
+ conv.ApplicationUserOid = current_user.Oid;
var msg = new AiConversationMessage();
msg.Message = system;