mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	restricting post replies if a thread is locked (returns pid of -1 instead)
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/posts.js
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/posts.js
									
									
									
									
									
								
							| @@ -157,9 +157,9 @@ var	RDB = require('./redis.js'), | ||||
|  | ||||
| 	Posts.reply = function(socket, tid, uid, content) { | ||||
| 		Posts.create(uid, tid, content, function(pid) { | ||||
| 			if (pid > 0) { | ||||
| 				RDB.rpush('tid:' + tid + ':posts', pid); | ||||
|  | ||||
|  | ||||
| 				socket.emit('event:alert', { | ||||
| 					title: 'Reply Successful', | ||||
| 					message: 'You have successfully replied. Click here to view your reply.', | ||||
| @@ -189,13 +189,22 @@ var	RDB = require('./redis.js'), | ||||
| 						] | ||||
| 					}); | ||||
| 				}); | ||||
| 			 | ||||
| 			} else { | ||||
| 				socket.emit('event:alert', { | ||||
| 					title: 'Reply Unsuccessful', | ||||
| 					message: 'Your reply could not be posted at this time. Please try again later.', | ||||
| 					type: 'notify', | ||||
| 					timeout: 2000 | ||||
| 				}); | ||||
| 			} | ||||
| 		}); | ||||
| 	}; | ||||
|  | ||||
| 	Posts.create = function(uid, tid, content, callback) { | ||||
| 		if (uid === null) return; | ||||
| 		 | ||||
| 		RDB.get('tid:' + tid + ':locked', function(locked) { | ||||
| 			if (!locked || locked === '0') { | ||||
| 				RDB.incr('global:next_post_id', function(pid) { | ||||
| 					// Posts Info | ||||
| 					RDB.set('pid:' + pid + ':content', content); | ||||
| @@ -213,6 +222,10 @@ var	RDB = require('./redis.js'), | ||||
| 					if (callback)  | ||||
| 						callback(pid); | ||||
| 				}); | ||||
| 			} else { | ||||
| 				callback(-1); | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user