post count is incrementing when replying

v1.18.x
Baris Usakli 12 years ago
parent 430e65a352
commit 3c86b43ba3

@ -69,7 +69,7 @@ var RDB = require('./redis.js'),
Posts.reply = function(socket, tid, uid, content) { Posts.reply = function(socket, tid, uid, content) {
Posts.create(uid, content, function(pid) { Posts.create(uid, tid, content, function(pid) {
RDB.rpush('tid:' + tid + ':posts', pid); RDB.rpush('tid:' + tid + ':posts', pid);
socket.emit('event:alert', { socket.emit('event:alert', {
@ -81,7 +81,7 @@ var RDB = require('./redis.js'),
}); });
}; };
Posts.create = function(uid, content, callback) { Posts.create = function(uid, tid, content, callback) {
if (uid === null) return; if (uid === null) return;
RDB.incr('global:next_post_id', function(pid) { RDB.incr('global:next_post_id', function(pid) {
@ -90,6 +90,8 @@ var RDB = require('./redis.js'),
RDB.set('pid:' + pid + ':uid', uid); RDB.set('pid:' + pid + ':uid', uid);
RDB.set('pid:' + pid + ':timestamp', new Date().getTime()); RDB.set('pid:' + pid + ':timestamp', new Date().getTime());
RDB.incr('tid:' + tid + ':postcount');
// User Details - move this out later // User Details - move this out later
RDB.lpush('uid:' + uid + ':posts', pid); RDB.lpush('uid:' + uid + ':posts', pid);

@ -75,7 +75,9 @@ var RDB = require('./redis.js'),
timestamp = replies[2]; timestamp = replies[2];
slug = replies[3]; slug = replies[3];
postcount = replies[4]; postcount = replies[4];
user.get_usernames_by_uids(uid, function(userNames) { user.get_usernames_by_uids(uid, function(userNames) {
var topics = []; var topics = [];
@ -116,8 +118,9 @@ var RDB = require('./redis.js'),
}); });
return; // for now, until anon code is written. return; // for now, until anon code is written.
} }
RDB.incr('global:next_topic_id', function(tid) { RDB.incr('global:next_topic_id', function(tid) {
// Global Topics // Global Topics
if (uid == null) uid = 0; if (uid == null) uid = 0;
if (uid !== null) { if (uid !== null) {
@ -141,7 +144,9 @@ var RDB = require('./redis.js'),
RDB.set('tid:' + tid + ':slug', slug); RDB.set('tid:' + tid + ':slug', slug);
RDB.set('tid:' + tid + ':timestamp', new Date().getTime()); RDB.set('tid:' + tid + ':timestamp', new Date().getTime());
RDB.incr('tid:' + tid + ':postcount'); RDB.incr('tid:' + tid + ':postcount');
RDB.set('topic:slug:' + slug + ':tid', tid); RDB.set('topic:slug:' + slug + ':tid', tid);
// Posts // Posts

Loading…
Cancel
Save