Skip to content
Snippets Groups Projects
Commit f67885f5 authored by Erick Hitter's avatar Erick Hitter
Browse files

Merge branch 'develop' into 'master'

Limit to a given user, and improve feedback

See merge request !5
parents a1038806 9d73e017
No related branches found
No related tags found
1 merge request!5Limit to a given user, and improve feedback
{ {
"command_user" : "",
"wp_endpoint" : "", "wp_endpoint" : "",
"wp_username" : "", "wp_username" : "",
"wp_password" : "", "wp_password" : "",
......
...@@ -28,7 +28,22 @@ app.get( '/', function( req, res ) { ...@@ -28,7 +28,22 @@ app.get( '/', function( req, res ) {
app.post( '/log', function( req, res ) { app.post( '/log', function( req, res ) {
// Don't bother if there's nothing to record // Don't bother if there's nothing to record
if ( 'undefined' === typeof req.body || 'undefined' === typeof req.body.text || ! req.body.text.length ) { if ( 'undefined' === typeof req.body || 'undefined' === typeof req.body.text || ! req.body.text.length ) {
return res.sendStatus( 400 ); var response = {
"response_type": "ephemeral",
"text": "Please provide something to record."
};
return res.status( 400 ).send( response );
}
// Limit who can trigger the command
if ( 'undefined' === typeof req.body.user_name || config.command_user !== req.body.user_name ) {
var response = {
"response_type": "ephemeral",
"text": "Sorry, you can't record completed tasks."
};
return res.status( 403 ).send( response );
} }
// Massage the title // Massage the title
...@@ -58,7 +73,7 @@ app.post( '/log', function( req, res ) { ...@@ -58,7 +73,7 @@ app.post( '/log', function( req, res ) {
"text": "**Entry recorded (**ID #" + resp.id + ", <" + resp.link + ">**)**\n" + resp.title.rendered "text": "**Entry recorded (**ID #" + resp.id + ", <" + resp.link + ">**)**\n" + resp.title.rendered
}; };
res.send( response); res.send( response );
} ); } );
} ); } );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment