|
|
@ -157,9 +157,9 @@ var RDB = require('./redis.js'),
|
|
|
|
|
|
|
|
|
|
|
|
Posts.reply = function(socket, tid, uid, content) {
|
|
|
|
Posts.reply = function(socket, tid, uid, content) {
|
|
|
|
Posts.create(uid, tid, content, function(pid) {
|
|
|
|
Posts.create(uid, tid, content, function(pid) {
|
|
|
|
|
|
|
|
if (pid > 0) {
|
|
|
|
RDB.rpush('tid:' + tid + ':posts', pid);
|
|
|
|
RDB.rpush('tid:' + tid + ':posts', pid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('event:alert', {
|
|
|
|
socket.emit('event:alert', {
|
|
|
|
title: 'Reply Successful',
|
|
|
|
title: 'Reply Successful',
|
|
|
|
message: 'You have successfully replied. Click here to view your reply.',
|
|
|
|
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) {
|
|
|
|
Posts.create = function(uid, tid, content, callback) {
|
|
|
|
if (uid === null) return;
|
|
|
|
if (uid === null) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RDB.get('tid:' + tid + ':locked', function(locked) {
|
|
|
|
|
|
|
|
if (!locked || locked === '0') {
|
|
|
|
RDB.incr('global:next_post_id', function(pid) {
|
|
|
|
RDB.incr('global:next_post_id', function(pid) {
|
|
|
|
// Posts Info
|
|
|
|
// Posts Info
|
|
|
|
RDB.set('pid:' + pid + ':content', content);
|
|
|
|
RDB.set('pid:' + pid + ':content', content);
|
|
|
@ -213,6 +222,10 @@ var RDB = require('./redis.js'),
|
|
|
|
if (callback)
|
|
|
|
if (callback)
|
|
|
|
callback(pid);
|
|
|
|
callback(pid);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
callback(-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|