mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	recent posts in /users/ page
This commit is contained in:
		
							
								
								
									
										33
									
								
								src/posts.js
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								src/posts.js
									
									
									
									
									
								
							| @@ -64,7 +64,7 @@ marked.setOptions({ | ||||
| 	}; | ||||
|  | ||||
| 	Posts.getPostsByPids = function(pids, current_user, callback) { | ||||
| 		var content = [], uid = [], timestamp = [], post_rep = [], editor = [], editTime = [], deleted = []; | ||||
| 		var content = [], uid = [], timestamp = [], post_rep = [], editor = [], editTime = [], deleted = [], tid = []; | ||||
|  | ||||
| 		for (var i=0, ii=pids.length; i<ii; i++) { | ||||
| 			content.push('pid:' + pids[i] + ':content'); | ||||
| @@ -74,6 +74,7 @@ marked.setOptions({ | ||||
| 			editor.push('pid:' + pids[i] + ':editor'); | ||||
| 			editTime.push('pid:' + pids[i] + ':edited'); | ||||
| 			deleted.push('pid:' + pids[i] + ':deleted'); | ||||
| 			tid.push('pid:' + pids[i] + ':tid'); | ||||
| 		} | ||||
|  | ||||
|  | ||||
| @@ -92,6 +93,7 @@ marked.setOptions({ | ||||
| 				.mget(editor) | ||||
| 				.mget(editTime) | ||||
| 				.mget(deleted) | ||||
| 				.mget(tid) | ||||
| 				.exec(function(err, replies) { | ||||
| 					post_data = { | ||||
| 						pid: pids, | ||||
| @@ -101,7 +103,8 @@ marked.setOptions({ | ||||
| 						reputation: replies[3], | ||||
| 						editor: replies[4], | ||||
| 						editTime: replies[5], | ||||
| 						deleted: replies[6] | ||||
| 						deleted: replies[6], | ||||
| 						tid: replies[7] | ||||
| 					}; | ||||
|  | ||||
| 					// below, to be deprecated | ||||
| @@ -302,5 +305,31 @@ marked.setOptions({ | ||||
| 			callback(raw); | ||||
| 		}); | ||||
| 	} | ||||
| 	 | ||||
| 	Posts.getPostsByUid = function(uid, callback) { | ||||
| 		 | ||||
| 		RDB.lrange('uid:' + uid + ':posts', 0, 10, function(err, pids) { | ||||
| 			if(err === null) { | ||||
| 				 | ||||
| 				Posts.getPostsByPids(pids, uid, function(posts) { | ||||
| 					var returnData = []; | ||||
| 					 | ||||
| 					var len = posts.postData.pid.length; | ||||
| 					 | ||||
| 					for (var i=0; i < len; ++i) { | ||||
| 						returnData.push({ | ||||
| 							pid: posts.postData.pid[i], | ||||
| 							content: posts.postData.content[i], | ||||
| 							timestamp: utils.relativeTime(posts.postData.timestamp[i]),							 | ||||
| 							tid: posts.postData.tid[i] | ||||
| 						}); | ||||
| 					}; | ||||
| 					 | ||||
| 					console.log(returnData); | ||||
| 					callback(returnData); | ||||
| 				}); | ||||
| 			} | ||||
| 		});				 | ||||
| 	} | ||||
|  | ||||
| }(exports)); | ||||
		Reference in New Issue
	
	Block a user