Skip to content

Node.js based forum software built for the modern web

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

Julian Lam570dfd978647
diff --git a/src/topics.js b/src/topics.js
index 4265e3b12c..caef722f6b 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -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', {
diff --git a/src/websockets.js b/src/websockets.js
index 321ed6e4ba..99d2559a96 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -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() {