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 1
1
using BotSharp . Abstraction . Routing ;
2
2
using Newtonsoft . Json . Serialization ;
3
3
using Newtonsoft . Json ;
4
- using BotSharp . Abstraction . Files . Models ;
5
- using BotSharp . Abstraction . Files ;
6
4
7
5
namespace BotSharp . OpenAPI . Controllers ;
8
6
@@ -138,6 +136,35 @@ public async Task<ConversationViewModel> GetConversation([FromRoute] string conv
138
136
return result ;
139
137
}
140
138
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
+
141
168
[ HttpDelete ( "/conversation/{conversationId}" ) ]
142
169
public async Task < bool > DeleteConversation ( [ FromRoute ] string conversationId )
143
170
{
You can’t perform that action at this time.
0 commit comments