File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed
src/Infrastructure/BotSharp.OpenAPI/Controllers Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change 11using BotSharp . Abstraction . Routing ;
22using Newtonsoft . Json . Serialization ;
33using Newtonsoft . Json ;
4- using BotSharp . Abstraction . Files . Models ;
5- using BotSharp . Abstraction . Files ;
64
75namespace BotSharp . OpenAPI . Controllers ;
86
@@ -138,6 +136,35 @@ public async Task<ConversationViewModel> GetConversation([FromRoute] string conv
138136 return result ;
139137 }
140138
139+ [ HttpGet ( "/conversation/{conversationId}/user" ) ]
140+ public async Task < UserViewModel > GetConversationUser ( [ FromRoute ] string conversationId )
141+ {
142+ var service = _services . GetRequiredService < IConversationService > ( ) ;
143+ var conversations = await service . GetConversations ( new ConversationFilter
144+ {
145+ Id = conversationId
146+ } ) ;
147+
148+ var userService = _services . GetRequiredService < IUserService > ( ) ;
149+ var conversation = conversations ? . Items ? . FirstOrDefault ( ) ;
150+ var userId = conversation == null ? _user . Id : conversation . UserId ;
151+ var user = await userService . GetUser ( userId ) ;
152+ if ( user == null )
153+ {
154+ return new UserViewModel
155+ {
156+ Id = _user . Id ,
157+ UserName = _user . UserName ,
158+ FirstName = _user . FirstName ,
159+ LastName = _user . LastName ,
160+ Email = _user . Email ,
161+ Source = "Unknown"
162+ } ;
163+ }
164+
165+ return UserViewModel . FromUser ( user ) ;
166+ }
167+
141168 [ HttpDelete ( "/conversation/{conversationId}" ) ]
142169 public async Task < bool > DeleteConversation ( [ FromRoute ] string conversationId )
143170 {
You can’t perform that action at this time.
0 commit comments