fixed broken mget implementation if no topics are present

v1.18.x
Julian Lam 12 years ago
parent a16f72e11c
commit 9e5a7b96b3

@ -5,8 +5,8 @@
redis = require('redis'),
db = redis.createClient();
// todo (holy cow): append,auth,bgrewriteaof,bgsave,bitcount,bitop,blpop,brpop,brpoplpush,client kill,client list,client getname,client setname,config get,config set,config resetstat,dbsize,debug object,debug segfault,decrby,del,discard,dump,echo,eval,evalsha,exec,exists,expire,expireat,flushall,flushdb,getbit,getrange,getset,hdel,hexists,hget,hgetall,hincrby,hincrbyfloat,hkeys,hlen,hmget,hmset,hset,hsetnx,hvals,incrby,incrbyfloat,info,keys,lastsave,lindex,linsert,llen,lpop,lpush,lpushx,lrange,lrem,lset,ltrim,mget,migrate,monitor,move,mset,msetnx,multi,object,persist,pexpire,pexpireat,ping,psetex,psubscribe,pttl,publish,punsubscribe,quit,randomkey,rename,renamenx,restore,rpop,rpoplpush,rpush,rpushx,sadd,save,scard,script exists,script flush,script kill,script load,sdiff,sdiffstore,select,setbit,setex,setnx,setrange,shutdown,sinter,sinterstore,sismember,slaveof,slowlog,smembers,smove,sort,spop,srandmember,srem,strlen,subscribe,sunion,sunionstore,sync,time,ttl,type,unsubscribe,unwatch,watch,zadd,zcard,zcount,zincrby,zinterstore,zrange,zrangebyscore,zrank,zrem,zremrangebyrank,zremrangebyscore,zrevrange,zrevrangebyscore,zrevrank,zscore,zunionstore
// done :^) get, set, incr, decr
// todo (holy cow): append,auth,bgrewriteaof,bgsave,bitcount,bitop,blpop,brpop,brpoplpush,client kill,client list,client getname,client setname,config get,config set,config resetstat,dbsize,debug object,debug segfault,decrby,discard,dump,echo,eval,evalsha,exec,exists,expireat,flushall,flushdb,getbit,getrange,getset,hdel,hexists,hget,hgetall,hincrby,hincrbyfloat,hkeys,hlen,hmget,hmset,hset,hsetnx,hvals,incrby,incrbyfloat,info,keys,lastsave,lindex,linsert,llen,lpop,lpushx,lrem,lset,ltrim,migrate,monitor,move,mset,msetnx,object,persist,pexpire,pexpireat,ping,psetex,psubscribe,pttl,publish,punsubscribe,quit,randomkey,rename,renamenx,restore,rpop,rpoplpush,rpush,rpushx,sadd,save,scard,script exists,script flush,script kill,script load,sdiff,sdiffstore,select,setbit,setex,setnx,setrange,shutdown,sinter,sinterstore,sismember,slaveof,slowlog,smembers,smove,sort,spop,srandmember,srem,strlen,subscribe,sunion,sunionstore,sync,time,ttl,type,unsubscribe,unwatch,watch,zadd,zcard,zcount,zincrby,zinterstore,zrange,zrangebyscore,zrank,zrem,zremrangebyrank,zremrangebyscore,zrevrange,zrevrangebyscore,zrevrank,zscore,zunionstore
// done: get, set, incr, decr, del, mget, multi, expire, lpush, lrange
function return_handler(error, data, callback, error_handler) {
if (error !== null) {

@ -53,33 +53,34 @@ var RDB = require('./redis.js'),
callback(topic_data);
});*/
RDB.multi()
.mget(title)
.mget(uid)
.mget(timestamp)
.mget(posts)
.exec(function(err, replies) {
title = replies[0];
uid = replies[1];
timestamp = replies[2];
posts = replies[3];
var topics = [];
for (var i=0, ii=title.length; i<ii; i++) {
topics.push({
'title' : title[i],
'uid' : uid[i],
'timestamp' : timestamp[i],
'posts' : posts[i],
'post_count' : 0
});
if (tids.length > 0) {
RDB.multi()
.mget(title)
.mget(uid)
.mget(timestamp)
.mget(posts)
.exec(function(err, replies) {
title = replies[0];
uid = replies[1];
timestamp = replies[2];
posts = replies[3];
var topics = [];
for (var i=0, ii=title.length; i<ii; i++) {
topics.push({
'title' : title[i],
'uid' : uid[i],
'timestamp' : timestamp[i],
'posts' : posts[i],
'post_count' : 0
});
}
callback(topics);
}
callback(topics);
});
);
} else callback([]);
});
}

@ -15,9 +15,16 @@ var express = require('express'),
}
}
function checkAuth(req, res, next) {
function hasAuth(req, res, next) {
// Include this middleware if the endpoint is publically accessible, but has elements that logged in users can see
}
function requireAuth(req, res, next) {
// Include this middleware if the endpoint requires a logged in user to view
console.log('REQUIRE: ', global.uid, req.sessionID);
if (!global.uid) {
res.send(403, 'You are not authorized to view this page');
req.redirect('/403');
} else {
next();
}
@ -63,11 +70,15 @@ var express = require('express'),
res.send(templates['header'] + templates['register'] + templates['footer']);
});
app.get('/account', checkAuth, function(req, res) {
app.get('/account', requireAuth, function(req, res) {
refreshTemplates();
res.send(templates['header'] + templates['account_settings'] + templates['footer']);
});
app.get('/403', function(req, res) {
res.send(403, 'You are not authorized to view this page');
});
module.exports.init = function() {
// todo move some of this stuff into config.json
app.configure(function() {

Loading…
Cancel
Save