mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fixes in posttools and thread tools for hashes
This commit is contained in:
		| @@ -56,13 +56,14 @@ marked.setOptions({ | ||||
|  | ||||
| 	PostTools.edit = function(uid, pid, title, content) { | ||||
| 		var	success = function() { | ||||
| 				RDB.set('pid:' + pid + ':content', content); | ||||
| 				RDB.set('pid:' + pid + ':edited', Date.now()); | ||||
| 				RDB.set('pid:' + pid + ':editor', uid); | ||||
| 			posts.setPostField(pid, 'content', content); | ||||
| 			posts.setPostField(pid, 'edited', Date.now()); | ||||
| 			posts.setPostField(pid, 'editor', uid); | ||||
|  | ||||
| 			posts.get_tid_by_pid(pid, function(tid) { | ||||
| 				PostTools.isMain(pid, tid, function(isMainPost) { | ||||
| 						if (isMainPost) RDB.set('tid:' + tid + ':title', title); | ||||
| 					if (isMainPost)  | ||||
| 						topics.setTopicField(tid, 'title', title); | ||||
|  | ||||
| 					io.sockets.in('topic_' + tid).emit('event:post_edited', { | ||||
| 						pid: pid, | ||||
| @@ -82,7 +83,7 @@ marked.setOptions({ | ||||
|  | ||||
| 	PostTools.delete = function(uid, pid) { | ||||
| 		var	success = function() { | ||||
| 				RDB.set('pid:' + pid + ':deleted', 1); | ||||
| 			posts.setPostField(pid, 'deleted', 1); | ||||
|  | ||||
| 			posts.get_tid_by_pid(pid, function(tid) { | ||||
| 				io.sockets.in('topic_' + tid).emit('event:post_deleted', { | ||||
|   | ||||
| @@ -128,6 +128,10 @@ marked.setOptions({ | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	Posts.setPostField = function(pid, field, value) { | ||||
| 		RDB.hset('post:' + pid, field, value); | ||||
| 	} | ||||
|  | ||||
| 	Posts.getPostFields = function(pid, fields, callback) { | ||||
| 		RDB.hmget('post:' + pid, fields, function(err, data) { | ||||
| 			if(err === null) { | ||||
|   | ||||
| @@ -39,7 +39,7 @@ var	RDB = require('./redis.js'), | ||||
| 		ThreadTools.privileges(tid, uid, function(privileges) { | ||||
| 			if (privileges.editable) { | ||||
| 				// Mark thread as locked | ||||
| 				RDB.set('tid:' + tid + ':locked', 1); | ||||
| 				topics.setTopicField(tid, 'locked', 1); | ||||
|  | ||||
| 				if (socket) { | ||||
| 					io.sockets.in('topic_' + tid).emit('event:topic_locked', { | ||||
| @@ -59,7 +59,6 @@ var	RDB = require('./redis.js'), | ||||
| 	ThreadTools.unlock = function(tid, uid, socket) { | ||||
| 		ThreadTools.privileges(tid, uid, function(privileges) { | ||||
| 			if (privileges.editable) { | ||||
| 				// Mark thread as unlocked | ||||
| 				RDB.del('tid:' + tid + ':locked'); | ||||
|  | ||||
| 				if (socket) { | ||||
| @@ -80,8 +79,8 @@ var	RDB = require('./redis.js'), | ||||
| 	ThreadTools.delete = function(tid, uid, socket) { | ||||
| 		ThreadTools.privileges(tid, uid, function(privileges) { | ||||
| 			if (privileges.editable) { | ||||
| 				// Mark thread as deleted | ||||
| 				RDB.set('tid:' + tid + ':deleted', 1); | ||||
| 				 | ||||
| 				topics.setTopicField(tid, 'deleted', 1); | ||||
| 				ThreadTools.lock(tid, uid); | ||||
|  | ||||
| 				if (socket) { | ||||
| @@ -102,8 +101,8 @@ var	RDB = require('./redis.js'), | ||||
| 	ThreadTools.restore = function(tid, uid, socket) { | ||||
| 		ThreadTools.privileges(tid, uid, function(privileges) { | ||||
| 			if (privileges.editable) { | ||||
| 				// Mark thread as restored | ||||
| 				RDB.del('tid:' + tid + ':deleted'); | ||||
|  | ||||
| 				topics.setTopicField(tid, 'deleted', 0); | ||||
| 				ThreadTools.unlock(tid, uid); | ||||
|  | ||||
| 				if (socket) { | ||||
| @@ -124,8 +123,8 @@ var	RDB = require('./redis.js'), | ||||
| 	ThreadTools.pin = function(tid, uid, socket) { | ||||
| 		ThreadTools.privileges(tid, uid, function(privileges) { | ||||
| 			if (privileges.editable) { | ||||
| 				// Mark thread as pinned | ||||
| 				RDB.set('tid:' + tid + ':pinned', 1); | ||||
| 				 | ||||
| 				topics.setTopicField(tid, 'pinned', 1); | ||||
|  | ||||
| 				if (socket) { | ||||
| 					io.sockets.in('topic_' + tid).emit('event:topic_pinned', { | ||||
| @@ -145,8 +144,8 @@ var	RDB = require('./redis.js'), | ||||
| 	ThreadTools.unpin = function(tid, uid, socket) { | ||||
| 		ThreadTools.privileges(tid, uid, function(privileges) { | ||||
| 			if (privileges.editable) { | ||||
| 				// Mark thread as unpinned | ||||
| 				RDB.del('tid:' + tid + ':pinned'); | ||||
| 				 | ||||
| 				topics.setTopicField(tid, 'pinned', 0); | ||||
|  | ||||
| 				if (socket) { | ||||
| 					io.sockets.in('topic_' + tid).emit('event:topic_unpinned', { | ||||
| @@ -169,10 +168,12 @@ var	RDB = require('./redis.js'), | ||||
|  | ||||
| 			RDB.smove('categories:' + oldCid + ':tid', 'categories:' + cid + ':tid', tid, function(err, result) { | ||||
| 				if (!err && result === 1) { | ||||
| 					RDB.set('tid:' + tid + ':cid', cid); | ||||
|  | ||||
| 					topics.setTopicField(tid, 'cid', cid); | ||||
|  | ||||
| 					categories.getCategories([cid], function(data) { | ||||
| 						RDB.set('tid:' + tid + ':category_name', data.categories[0].name); | ||||
| 						RDB.set('tid:' + tid + ':category_slug', data.categories[0].slug); | ||||
| 						topics.setTopicField(tid, 'category_name', data.categories[0].name); | ||||
| 						topics.setTopicField(tid, 'category_slug', data.categories[0].slug); | ||||
| 					}); | ||||
|  | ||||
| 					socket.emit('api:topic.move', { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user