File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ messagesController.get = function (req, res) {
9090 } )
9191}
9292
93- messagesController . getConversation = function ( req , res ) {
93+ messagesController . getConversation = async ( req , res ) => {
9494 const cid = req . params . convoid
9595 if ( _ . isUndefined ( cid ) ) return handleError ( res , 'Invalid Conversation ID!' )
9696
@@ -181,6 +181,16 @@ messagesController.getConversation = function (req, res) {
181181 }
182182
183183 const c = convo . toObject ( )
184+
185+ let isPart = false
186+ _ . each ( c . participants , function ( p ) {
187+ if ( p . _id . toString ( ) === req . user . _id . toString ( ) ) isPart = true
188+ } )
189+
190+ if ( ! isPart ) {
191+ return res . redirect ( '/messages' )
192+ }
193+
184194 messageSchema . getConversationWithObject (
185195 { cid : c . _id , userMeta : convo . userMeta , requestingUser : req . user } ,
186196 function ( err , messages ) {
You can’t perform that action at this time.
0 commit comments