Skip to content

Commit

Permalink
send last inserted id back to client
Browse files Browse the repository at this point in the history
  • Loading branch information
gka committed Oct 20, 2017
1 parent 2cb6110 commit 5794f5b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ function run(db) {
if (!user) return error('access denied', request, reply, 403);
checkValidComment(db, slug, user.id, comment, (err) => {
if (err) return reply.send({ status: 'rejected', reason: err });
db.run(queries.insert, [user.id, slug, comment], (err) => {
if (error(err, request, reply)) return;
let stmt = db
.prepare(queries.insert, [user.id, slug, comment])
.run(err => {
if (err) return error(err, request, reply);
if (!user.blocked && !user.trusted) {
awaiting_moderation.push({slug});
}
reply.send({ status: 'ok' });
reply.send({ status: 'ok', id: stmt.lastID });
});
});
});
Expand Down

0 comments on commit 5794f5b

Please sign in to comment.