mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	notifications page + ajaxify route + css styling
This commit is contained in:
		
							
								
								
									
										30
									
								
								src/user.js
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								src/user.js
									
									
									
									
									
								
							| @@ -945,6 +945,36 @@ var utils = require('./../public/src/utils.js'), | ||||
| 				callback(notifications); | ||||
| 			}); | ||||
| 		}, | ||||
| 		getAll: function(uid, limit, before, callback) { | ||||
| 			var	now = new Date(); | ||||
|  | ||||
| 			if (!limit || parseInt(limit) <= 0) limit = 25; | ||||
| 			if (before) before = new Date(parseInt(before, 10)); | ||||
|  | ||||
| 			RDB.multi() | ||||
| 				.zrevrangebyscore('uid:' + uid + ':notifications:read', before ? before.getTime(): now.getTime(), -Infinity, 'LIMIT', 0, limit) | ||||
| 				.zrevrangebyscore('uid:' + uid + ':notifications:unread', before ? before.getTime(): now.getTime(), -Infinity, 'LIMIT', 0, limit) | ||||
| 				.exec(function(err, results) { | ||||
| 					// Merge the read and unread notifications | ||||
| 					var	nids = results[0].concat(results[1]); | ||||
|  | ||||
| 					async.map(nids, function(nid, next) { | ||||
| 						notifications.get(nid, function(notif_data) { | ||||
| 							next(null, notif_data); | ||||
| 						}); | ||||
| 					}, function(err, notifs) { | ||||
| 						notifs = notifs.sort(function(a, b) { | ||||
| 							return parseInt(b.datetime, 10) - parseInt(a.datetime, 10); | ||||
| 						}).map(function(notif) { | ||||
| 							notif.datetimeISO = new Date(parseInt(notif.datetime, 10)).toISOString(); | ||||
|  | ||||
| 							return notif; | ||||
| 						}); | ||||
|  | ||||
| 						callback(err, notifs); | ||||
| 					}) | ||||
| 				}); | ||||
| 		}, | ||||
| 		getUnreadCount: function(uid, callback) { | ||||
| 			RDB.zcount('uid:' + uid + ':notifications:unread', 0, 10, callback); | ||||
| 		}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user