updated topics module to use uid as a passed in param, instead of through global.uid

v1.18.x
Julian Lam 12 years ago
parent 33f155b2d1
commit 570dfd9786

@ -99,8 +99,8 @@ var RDB = require('./redis.js'),
}
Topics.post = function(title, content, category) {
if (global.uid === null) {
Topics.post = function(uid, title, content, category) {
if (uid === 0) {
global.socket.emit('event:alert', {
title: 'Thank you for posting',
message: 'Since you are unregistered, your post is awaiting approval. Click here to register now.',
@ -115,8 +115,8 @@ var RDB = require('./redis.js'),
RDB.incr('global:next_topic_id', function(tid) {
// Global Topics
if (global.uid == null) global.uid = 0;
if (global.uid !== null) {
if (uid == null) uid = 0;
if (uid !== null) {
RDB.lpush('topics:tid', tid);
} else {
// need to add some unique key sent by client so we can update this with the real uid later
@ -133,7 +133,7 @@ var RDB = require('./redis.js'),
// Topic Info
RDB.set('tid:' + tid + ':title', title);
RDB.set('tid:' + tid + ':uid', global.uid);
RDB.set('tid:' + tid + ':uid', uid);
RDB.set('tid:' + tid + ':slug', slug);
RDB.set('tid:' + tid + ':timestamp', new Date().getTime());
RDB.incr('tid:' + tid + ':postcount');
@ -147,7 +147,7 @@ var RDB = require('./redis.js'),
// User Details - move this out later
RDB.lpush('uid:' + global.uid + ':topics', tid);
RDB.lpush('uid:' + uid + ':topics', tid);
global.socket.emit('event:alert', {

@ -86,7 +86,7 @@ var SocketIO = require('socket.io').listen(global.server),
});
socket.on('api:topics.post', function(data) {
modules.topics.post(data.title, data.content);
modules.topics.post(uid, data.title, data.content);
});
socket.on('api:user.active.get', function() {

Loading…
Cancel
Save