nodebb-plugin-poll
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -17,10 +17,12 @@ var NodeBB = require('./nodebb'), | ||
Hooks.filter.postSave = function(postData, callback) { | ||
// Is this the first post? | ||
NodeBB.Topics.getPostCount(postData.tid, function(err, postCount) { | ||
if (parseInt(postCount, 10) !== 0) { | ||
return callback(null, postData); | ||
} | ||
if (Serializer.hasMarkup(postData.content)) { | ||
// Is this the first post? | ||
NodeBB.Topics.getPostCount(postData.tid, function(err, postCount) { | ||
if (parseInt(postCount, 10) !== 0) { | ||
return callback(null, postData); | ||
} | ||
savePoll(postData, callback); | ||
}); | ||
savePoll(postData, callback); | ||
}); | ||
} | ||
}; | ||
@@ -38,18 +40,22 @@ | ||
canCreate(result.cid, obj.post.editor, function(err, canCreate) { | ||
if (err) { | ||
return callback(err, obj); | ||
} | ||
savePoll(obj.post, function(err, postData) { | ||
if (err || !postData.pollId) { | ||
if (Serializer.hasMarkup(obj.post.content)) { | ||
canCreate(result.cid, obj.post.editor, function (err, canCreate) { | ||
if (err) { | ||
return callback(err, obj); | ||
} | ||
// NodeBB only updates the edited, editor and content fields, so we add the pollId field manually. | ||
NodeBB.Posts.setPostField(obj.post.pid, 'pollId', postData.pollId, function() { | ||
callback(null, obj); | ||
savePoll(obj.post, function (err, postData) { | ||
if (err || !postData.pollId) { | ||
return callback(err, obj); | ||
} | ||
// NodeBB only updates the edited, editor and content fields, so we add the pollId field manually. | ||
NodeBB.Posts.setPostField(obj.post.pid, 'pollId', postData.pollId, function () { | ||
callback(null, obj); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
return callback(null, obj); | ||
} | ||
}); | ||
@@ -56,0 +62,0 @@ }; |
@@ -5,3 +5,4 @@ "use strict"; | ||
NodeBB = require('./nodebb'), | ||
async = require('async'); | ||
async = require('async'), | ||
winston = require.main.require('winston'); | ||
@@ -20,3 +21,3 @@ (function(Upgrade) { | ||
async.each(cids, function(cid, next) { | ||
console.log(cid); | ||
winston.verbose('[plugin/poll] Upgrading cid ' + cid); | ||
NodeBB.Privileges.categories.give(['poll:create'], cid, 'registered-users', next); | ||
@@ -23,0 +24,0 @@ }, next); |
{ | ||
"name": "nodebb-plugin-poll", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "NodeBB Poll Plugin", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
Sorry, the diff of this file is not supported yet
2033
197338