wip
This commit is contained in:
		
							parent
							
								
									e21ab77dd5
								
							
						
					
					
						commit
						ef5a963b32
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
 * Module dependencies
 | 
					 * Module dependencies
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
import Message from '../../models/messaging-message';
 | 
					import Message from '../../models/messaging-message';
 | 
				
			||||||
 | 
					import Mute from '../../models/mute';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Get count of unread messages
 | 
					 * Get count of unread messages
 | 
				
			||||||
| 
						 | 
					@ -11,8 +12,17 @@ import Message from '../../models/messaging-message';
 | 
				
			||||||
 * @return {Promise<any>}
 | 
					 * @return {Promise<any>}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
module.exports = (params, user) => new Promise(async (res, rej) => {
 | 
					module.exports = (params, user) => new Promise(async (res, rej) => {
 | 
				
			||||||
 | 
						const mute = await Mute.find({
 | 
				
			||||||
 | 
							muter_id: user._id,
 | 
				
			||||||
 | 
							deleted_at: { $exists: false }
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
						const mutedUserIds = mute.map(m => m.mutee_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const count = await Message
 | 
						const count = await Message
 | 
				
			||||||
		.count({
 | 
							.count({
 | 
				
			||||||
 | 
								user_id: {
 | 
				
			||||||
 | 
									$nin: mutedUserIds
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
			recipient_id: user._id,
 | 
								recipient_id: user._id,
 | 
				
			||||||
			is_read: false
 | 
								is_read: false
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue