Permalink
Browse files

fixes #18, the handle/delete commands did not send the correct id for…

… the targeted comment
  • Loading branch information...
1 parent 02e3b60 commit bfef430cc65b66e2b0bd67edf939b4b20a169fc3 @bennage committed Mar 26, 2012
Showing with 12 additions and 12 deletions.
  1. +4 −4 lib/routes.js
  2. +8 −8 lib/table.js
View
@@ -29,28 +29,28 @@ module.exports = {
handleComment: function(req, res) {
var documentId = req.params.file,
- commentId = req.params.commentId;
+ hash = req.params.commentId;
// only an admin can set this flag
if (req.context.user.__pundit_role__ !== 'admin') {
res.send(403);
}
- store.handleComment(documentId, commentId);
+ store.handleComment(documentId, req.context.user.__pundit_id__ + hash);
res.send(200);
},
deleteComment: function(req, res) {
var documentId = req.params.file,
- commentId = req.params.commentId;
+ hash = req.params.commentId;
// only an admin can set this flag
if (req.context.user.__pundit_role__ !== 'admin') {
res.send(403);
}
- store.deleteComment(documentId, commentId);
+ store.deleteComment(documentId, req.context.user.__pundit_id__ + hash);
res.send(200);
},
View
@@ -1,5 +1,4 @@
-var uuid = require('node-uuid'),
- azure = require('azure');
+var azure = require('azure');
var config = require('./config');
@@ -13,9 +12,9 @@ var settings = {},
var service = azure.ServiceClient,
TableQuery = azure.TableQuery;
-var partition = 'part1';
-var tableName = 'config';
-var rowKey = 'default';
+var partition = 'part1',
+ tableName = 'config',
+ rowKey = 'default';
var client = azure.createTableService();
@@ -95,12 +94,13 @@ function saveCommentFor(file, comment) {
comment.RowKey = comment.author_login + comment.hash;
//todo: replace with insertOrReplaceEntity
-client.queryEntity(table, partition, comment.RowKey, function(err, result) {
+ client.queryEntity(table, partition, comment.RowKey, function(err, result) {
if (err && err.code === 'ResourceNotFound') {
client.insertEntity(table, comment, function(err) {
- if (err) console.dir(err);console.log('comment saved');
+ if (err) console.dir(err);
+ console.log('comment saved');
});
} else {
@@ -109,7 +109,7 @@ client.queryEntity(table, partition, comment.RowKey, function(err, result) {
console.log('comment updated');
});
}
- });
+ });
}
function handleComment(file, commentId) {

0 comments on commit bfef430

Please sign in to comment.