mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	closes #107
This commit is contained in:
		| @@ -314,6 +314,32 @@ var	RDB = require('./redis.js'), | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	Categories.moveRecentReplies = function(tid, oldCid, cid, callback) { | ||||
| 		topics.getPids(tid, function(err, pids) { | ||||
| 			if(!err) { | ||||
|  | ||||
| 				function movePost(pid, callback) { | ||||
| 					posts.getPostField(pid, 'timestamp', function(timestamp) { | ||||
| 						RDB.zrem('categories:recent_posts:cid:' + oldCid, pid);	 | ||||
| 						RDB.zadd('categories:recent_posts:cid:' + cid, timestamp, pid);	 | ||||
| 					}); | ||||
| 				} | ||||
|  | ||||
| 				async.each(pids, movePost, function(err) { | ||||
| 					if(!err) { | ||||
| 						callback(null, 1) | ||||
| 					} else { | ||||
| 						console.log(err); | ||||
| 						callback(err, null); | ||||
| 					} | ||||
| 				}); | ||||
| 			} else { | ||||
| 				console.log(err); | ||||
| 				callback(err, null); | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	Categories.getCategoryData = function(cid, callback) { | ||||
| 		RDB.hgetall('category:' + cid, function(err, data) { | ||||
| 			if(err === null) | ||||
|   | ||||
| @@ -218,9 +218,9 @@ marked.setOptions({ | ||||
|  | ||||
| 			Posts.create(uid, tid, content, images, function(postData) { | ||||
| 				if (postData) { | ||||
| 					RDB.rpush('tid:' + tid + ':posts', postData.pid); | ||||
| 					topics.addPostToTopic(tid, postData.pid); | ||||
|  | ||||
| 					RDB.del('tid:' + tid + ':read_by_uid');  | ||||
| 					topics.markUnRead(tid); | ||||
|  | ||||
| 					Posts.get_cid_by_pid(postData.pid, function(cid) { | ||||
| 						RDB.del('cid:' + cid + ':read_by_uid', function(err, data) { | ||||
|   | ||||
| @@ -171,6 +171,12 @@ var	RDB = require('./redis.js'), | ||||
|  | ||||
| 					topics.setTopicField(tid, 'cid', cid); | ||||
| 					 | ||||
| 					categories.moveRecentReplies(tid, oldCid, cid, function(err, data) { | ||||
| 						if(err) { | ||||
| 							console.log(err); | ||||
| 						} | ||||
| 					}); | ||||
|  | ||||
| 					categories.incrementCategoryFieldBy(oldCid, 'topic_count', -1); | ||||
| 					categories.incrementCategoryFieldBy(cid, 'topic_count', 1); | ||||
|  | ||||
|   | ||||
| @@ -226,6 +226,10 @@ marked.setOptions({ | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	Topics.markUnRead = function(tid) { | ||||
| 		RDB.del('tid:' + tid + ':read_by_uid');  | ||||
| 	} | ||||
|  | ||||
| 	Topics.markAsRead = function(tid, uid) { | ||||
| 		 | ||||
| 		RDB.sadd(schema.topics(tid).read_by_uid, uid); | ||||
| @@ -455,4 +459,12 @@ marked.setOptions({ | ||||
| 		Topics.setTopicField(tid, 'lastposttime', timestamp); | ||||
| 	} | ||||
| 	 | ||||
| 	Topics.addPostToTopic = function(tid, pid) { | ||||
| 		RDB.rpush('tid:' + tid + ':posts', pid); | ||||
| 	} | ||||
|  | ||||
| 	Topics.getPids = function(tid, callback) { | ||||
| 		RDB.lrange('tid:' + tid + ':posts', 0, -1, callback); | ||||
| 	} | ||||
|  | ||||
| }(exports)); | ||||
		Reference in New Issue
	
	Block a user