Skip to content

Node.js based forum software built for the modern web

hinting

psychobunny28704a616417
diff --git a/src/feed.js b/src/feed.js
index f7a57ecf94..c765c152dc 100644
--- a/src/feed.js
+++ b/src/feed.js
@@ -1,4 +1,4 @@
-(function(Feed) {
+(function (Feed) {
var RDB = require('./redis.js'),
schema = require('./schema.js'),
posts = require('./posts.js'),
@@ -15,20 +15,20 @@
baseUrl: nconf.get('url') + 'feeds'
};
- Feed.saveFeed = function(location, feed, callback) {
+ Feed.saveFeed = function (location, feed, callback) {
var savePath = path.join(__dirname, '../', location);
- fs.writeFile(savePath, feed.xml(), function(err) {
+ fs.writeFile(savePath, feed.xml(), function (err) {
if (err) return winston.err(err);
if (callback) callback(err);
});
}
- Feed.updateTopic = function(tid, callback) {
+ Feed.updateTopic = function (tid, callback) {
if (process.env.NODE_ENV === 'development') winston.info('[rss] Updating RSS feeds for topic ' + tid);
- topics.getTopicWithPosts(tid, 0, 0, -1, function(err, topicData) {
+ topics.getTopicWithPosts(tid, 0, 0, -1, function (err, topicData) {
if (err) return callback(new Error('topic-invalid'));
var feed = new rss({
@@ -62,16 +62,16 @@
}
}
- Feed.saveFeed('feeds/topics/' + tid + '.rss', feed, function(err) {
+ Feed.saveFeed('feeds/topics/' + tid + '.rss', feed, function (err) {
if (callback) callback();
});
});
};
- Feed.updateCategory = function(cid, callback) {
+ Feed.updateCategory = function (cid, callback) {
if (process.env.NODE_ENV === 'development') winston.info('[rss] Updating RSS feeds for category ' + cid);
- categories.getCategoryById(cid, 0, function(err, categoryData) {
+ categories.getCategoryById(cid, 0, function (err, categoryData) {
if (err) return callback(new Error('category-invalid'));
var feed = new rss({
@@ -100,7 +100,7 @@
});
}
- Feed.saveFeed('feeds/categories/' + cid + '.rss', feed, function(err) {
+ Feed.saveFeed('feeds/categories/' + cid + '.rss', feed, function (err) {
if (callback) callback();
});
});
diff --git a/src/groups.js b/src/groups.js
index 5a30ea95aa..fde915f448 100644
--- a/src/groups.js
+++ b/src/groups.js
@@ -1,95 +1,117 @@
-var async = require('async'),
- User = require('./user'),
- RDB = RDB || require('./redis'),
- Groups = {
- list: function(options, callback) {
- RDB.hvals('group:gid', function(err, gids) {
- if (gids.length > 0) {
- async.map(gids, function(gid, next) {
- Groups.get(gid, {
- expand: options.expand
- }, next);
- }, function(err, groups) {
- callback(err, groups.filter(function(group) {
- if (group.deleted === '1') return false;
- else return true;
- }));
- });
- } else callback(null, []);
- });
- },
- get: function(gid, options, callback) {
- async.parallel({
- base: function(next) {
- RDB.hgetall('gid:' + gid, next);
- },
- users: function(next) {
- RDB.smembers('gid:' + gid + ':members', function(err, uids) {
- if (options.expand) {
- if (err) return next(err);
+(function () {
+ "use strict";
- async.map(uids, function(uid, next) {
- User.getUserData(uid, next);
- }, function(err, users) {
- next(err, users);
- });
- } else next(err, uids);
- });
- }
- }, function(err, results) {
- if (err) return callback(err);
+ var async = require('async'),
+ User = require('./user'),
+ RDB = RDB || require('./redis'),
+ Groups = {
+ list: function (options, callback) {
+ RDB.hvals('group:gid', function (err, gids) {
+ if (gids.length > 0) {
+ async.map(gids, function (gid, next) {
+ Groups.get(gid, {
+ expand: options.expand
+ }, next);
+ }, function (err, groups) {
+ callback(err, groups.filter(function (group) {
+ if (group.deleted === '1') {
+ return false;
+ } else {
+ return true;
+ }
+ }));
+ });
+ } else {
+ callback(null, []);
+ }
+ });
+ },
+ get: function (gid, options, callback) {
+ async.parallel({
+ base: function (next) {
+ RDB.hgetall('gid:' + gid, next);
+ },
+ users: function (next) {
+ RDB.smembers('gid:' + gid + ':members', function (err, uids) {
+ if (options.expand) {
+ if (err) {
+ return next(err);
+ }
+
+ async.map(uids, function (uid, next) {
+ User.getUserData(uid, next);
+ }, function (err, users) {
+ next(err, users);
+ });
+ } else {
+ next(err, uids);
+ }
+ });
+ }
+ }, function (err, results) {
+ if (err) {
+ return callback(err);
+ }
- results.base.count = results.users.length;
- results.base.members = results.users;
+ results.base.count = results.users.length;
+ results.base.members = results.users;
- callback(err, results.base);
- });
- },
- getGidFromName: function(name, callback) {
- RDB.hget('group:gid', name, callback);
- },
- isMember: function(uid, gid, callback) {
- RDB.sismember('gid:' + gid + ':members', uid, callback);
- },
- exists: function(name, callback) {
- RDB.hexists('group:gid', name, callback);
- },
- create: function(name, description, callback) {
- if (name.length === 0) return callback(new Error('name-too-short'));
+ callback(err, results.base);
+ });
+ },
+ getGidFromName: function (name, callback) {
+ RDB.hget('group:gid', name, callback);
+ },
+ isMember: function (uid, gid, callback) {
+ RDB.sismember('gid:' + gid + ':members', uid, callback);
+ },
+ exists: function (name, callback) {
+ RDB.hexists('group:gid', name, callback);
+ },
+ create: function (name, description, callback) {
+ if (name.length === 0) {
+ return callback(new Error('name-too-short'));
+ }
- Groups.exists(name, function(err, exists) {
- if (!exists) {
- RDB.incr('next_gid', function(err, gid) {
- RDB.multi()
- .hset('group:gid', name, gid)
- .hmset('gid:' + gid, {
- gid: gid,
- name: name,
- description: description,
- deleted: '0'
- })
- .exec(function(err) {
- Groups.get(gid, {}, callback);
- });
- });
- } else callback(new Error('group-exists'))
- });
- },
- update: function(gid, values, callback) {
- RDB.exists('gid:' + gid, function(err, exists) {
- if (!err && exists) RDB.hmset('gid:' + gid, values, callback);
- else calback(new Error('gid-not-found'));
- });
- },
- destroy: function(gid, callback) {
- RDB.hset('gid:' + gid, 'deleted', '1', callback);
- },
- join: function(gid, uid, callback) {
- RDB.sadd('gid:' + gid + ':members', uid, callback);
- },
- leave: function(gid, uid, callback) {
- RDB.srem('gid:' + gid + ':members', uid, callback);
- }
- };
+ Groups.exists(name, function (err, exists) {
+ if (!exists) {
+ RDB.incr('next_gid', function (err, gid) {
+ RDB.multi()
+ .hset('group:gid', name, gid)
+ .hmset('gid:' + gid, {
+ gid: gid,
+ name: name,
+ description: description,
+ deleted: '0'
+ })
+ .exec(function (err) {
+ Groups.get(gid, {}, callback);
+ });
+ });
+ } else {
+ callback(new Error('group-exists'));
+ }
+ });
+ },
+ update: function (gid, values, callback) {
+ RDB.exists('gid:' + gid, function (err, exists) {
+ if (!err && exists) {
+ RDB.hmset('gid:' + gid, values, callback);
+ } else {
+ callback(new Error('gid-not-found'));
+ }
+ });
+ },
+ destroy: function (gid, callback) {
+ RDB.hset('gid:' + gid, 'deleted', '1', callback);
+ },
+ join: function (gid, uid, callback) {
+ RDB.sadd('gid:' + gid + ':members', uid, callback);
+ },
+ leave: function (gid, uid, callback) {
+ RDB.srem('gid:' + gid + ':members', uid, callback);
+ }
+ };
-module.exports = Groups;
\ No newline at end of file
+ module.exports = Groups;
+}());
\ No newline at end of file
diff --git a/src/imgur.js b/src/imgur.js
index 8fffa0ff66..7d4542be3c 100644
--- a/src/imgur.js
+++ b/src/imgur.js
@@ -1,10 +1,12 @@
var request = require('request');
-(function(imgur) {
+(function (imgur) {
+ "use strict";
+
var clientID = '';
- imgur.upload = function(image, type, callback) {
+ imgur.upload = function (image, type, callback) {
var options = {
url: 'https://api.imgur.com/3/upload.json',
headers: {
@@ -12,7 +14,7 @@ var request = require('request');
}
};
- var post = request.post(options, function(err, req, body) {
+ var post = request.post(options, function (err, req, body) {
try {
callback(err, JSON.parse(body));
} catch (e) {
@@ -24,10 +26,10 @@ var request = require('request');
type: type,
image: image
});
- }
+ };
- imgur.setClientID = function(id) {
+ imgur.setClientID = function (id) {
clientID = id;
- }
+ };
}(exports));
\ No newline at end of file