File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,13 @@ export class ConversationController {
9090 try {
9191 let conversationBody = request . body ;
9292 conversationBody . members . push ( request [ 'user' ] . _id ) ;
93- const conversation = await this . conversationRepository . create ( request . body ) ;
93+ const conversationAray = await this . conversationRepository . retrieve ( { members : { "$all" : conversationBody . members } } ) ;
94+ let conversation ;
95+ if ( conversationAray . length ) {
96+ conversation = conversationAray [ 0 ] ;
97+ } else {
98+ conversation = await this . conversationRepository . create ( request . body ) ;
99+ }
94100 response . send ( CumtomResponse . success ( conversation , 'Conversation created' ) ) ;
95101 } catch ( error ) {
96102 throw CumtomResponse . serverError ( error , 'Error' ) ;
You can’t perform that action at this time.
0 commit comments