Package com.axelor.ai.chat
Class ChatAccess
java.lang.Object
com.axelor.ai.chat.ChatAccess
Membership resolution for shared chats. The invite is the permission boundary: any
AiChatParticipant row grants the read column (list, messages, stream resume). Driving — agent
turns, tool approvals, the subject — extends to PROMPTER via canDrive(com.axelor.ai.db.AiChat, com.axelor.auth.db.User); administration
(rename, delete, invite/remove, mode, the space mark, claims) stays with the owner (
createdBy, whose meaning is never widened).-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTrue whenusermay drive (run an agent turn in) this chat: the owner, always, or a PROMPTER.static AiChatfindMemberChat(String uuid, User user) The chat whenuseris its owner or an invited member, else null.static LongfindMemberChatId(String uuid, User user) LikefindMemberChat(java.lang.String, com.axelor.auth.db.User), but returns only the primary key, loading no entity — so a caller can take a pessimistic lock as the row's first read.static booleanhasForeignUserMessage(String chatUuid, User user) True when the chat's history contains a USER message authored by someone other thanuser— i.e.static booleanisDiscussion(AiChat chat) True when a driver's plain message goes to the members rather than the agent.static booleanisTurnInitiator(String chatUuid, User user) True whenuseris the member whose run the chat's latest assistant turn is — the row's author.memberCodes(String uuid) User codes of everyone who can see the chat: the owner plus invited participants.static AiChatConversationModeThe chat's conversation mode; AUTO for rows created before the column existed.static LongThe chat owner's id (createdBy), or null when the chat does not exist.static UUIDstatic AiChatParticipantparticipantOf(AiChat chat, User user) The user's participant row on the chat, or null (owners have none — seeroleOf(com.axelor.ai.db.AiChat, com.axelor.auth.db.User)).static ChatAccess.RoleroleOf(AiChatParticipant participant) The participant row's role, or null.static ChatAccess.RoleThe user's role on the chat, or null for a non-member.The{id, code, name}shape used for server-derived attribution everywhere.
-
Method Details
-
userRef
The{id, code, name}shape used for server-derived attribution everywhere. -
memberCodes
User codes of everyone who can see the chat: the owner plus invited participants. -
findMemberChat
The chat whenuseris its owner or an invited member, else null. -
findMemberChatId
LikefindMemberChat(java.lang.String, com.axelor.auth.db.User), but returns only the primary key, loading no entity — so a caller can take a pessimistic lock as the row's first read. (Locking an already-loaded entity is a version-checked upgrade that fails when another transaction commits in between.) -
ownerIdOf
The chat owner's id (createdBy), or null when the chat does not exist. A scalar read for per-turn gates that need the ownership answer without loading the row. -
parseUuid
-
hasForeignUserMessage
True when the chat's history contains a USER message authored by someone other thanuser— i.e. untrusted text sits in the prompt window. Mutation approval (the confused-deputy mitigation) keys on this rather than on the discussion-mode flag: a summoner alone with the agent gets no friction, and once foreign text exists it stays in the replay forever, so the guard stays on. -
isTurnInitiator
True whenuseris the member whose run the chat's latest assistant turn is — the row's author. An approval, like an interactive prompt, is that member's consent act: the tool executes with their permissions, so no other driver may answer it (see the streamer's sanitizeApprovedToolMessage, which validates the same thing on the resume path). -
participantOf
The user's participant row on the chat, or null (owners have none — seeroleOf(com.axelor.ai.db.AiChat, com.axelor.auth.db.User)). -
roleOf
The user's role on the chat, or null for a non-member. -
canDrive
True whenusermay drive (run an agent turn in) this chat: the owner, always, or a PROMPTER. Mode does not enter into it — mode decides whether a driver's plain message runs a turn, never whether they are allowed to run one. Every write path must agree on this, or a summon admitted by one is silently dropped by another. -
modeOf
The chat's conversation mode; AUTO for rows created before the column existed. -
isDiscussion
True when a driver's plain message goes to the members rather than the agent. -
roleOf
The participant row's role, or null.
-