mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Can get the number of unread notifications
This commit is contained in:
		
							
								
								
									
										28
									
								
								src/helpers/NotificationsHelper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/helpers/NotificationsHelper.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
import { DatabaseHelper } from "./DatabaseHelper";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Notifications helper
 | 
			
		||||
 * 
 | 
			
		||||
 * @author Pierre HUBERT
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const NOTIFICATIONS_TABLE = "comunic_notifications";
 | 
			
		||||
 | 
			
		||||
export class NotificationsHelper {
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Count the number of unread notifications of a user
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param userID Target user ID
 | 
			
		||||
	 */
 | 
			
		||||
	public static async CountUnread(userID: number) : Promise<number> {
 | 
			
		||||
		return await DatabaseHelper.Count({
 | 
			
		||||
			table: NOTIFICATIONS_TABLE,
 | 
			
		||||
			where: {
 | 
			
		||||
				dest_user_id: userID,
 | 
			
		||||
				seen: 0
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user