Skip to content
Snippets Groups Projects

Mattermost/Slack send a JSON payload for a Slash command

Merged Erick Hitter requested to merge develop into master
1 file
+ 4
4
Compare changes
  • Side-by-side
  • Inline
+ 4
4
@@ -7,7 +7,7 @@ var WPAPI = require( 'wpapi' );
@@ -7,7 +7,7 @@ var WPAPI = require( 'wpapi' );
var striptags = require( 'striptags' );
var striptags = require( 'striptags' );
var app = express();
var app = express();
app.use( bodyParser.text() );
app.use( bodyParser.json() );
app.use( bodyParser.urlencoded( { extended: true } ) );
app.use( bodyParser.urlencoded( { extended: true } ) );
// Config
// Config
@@ -27,12 +27,12 @@ app.get( '/', function( req, res ) {
@@ -27,12 +27,12 @@ app.get( '/', function( req, res ) {
// Parse POST body to create WP post
// Parse POST body to create WP post
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 || ! req.body.length ) {
if ( 'undefined' === typeof req.body || 'undefined' === typeof req.body.text || ! req.body.text.length ) {
return res.sendStatus( 400 );
return res.sendStatus( 400 );
}
}
// Massage the title
// Massage the title
var title = req.body;
var title = req.body.text;
title = striptags( title, [] );
title = striptags( title, [] );
if ( title.length > 30 ) {
if ( title.length > 30 ) {
@@ -43,7 +43,7 @@ app.post( '/log', function( req, res ) {
@@ -43,7 +43,7 @@ app.post( '/log', function( req, res ) {
}
}
// Decorate the content
// Decorate the content
var content = req.body;
var content = req.body.text;
content = striptags( content, [ 'a', 'code', 'strong', 'em' ] );
content = striptags( content, [ 'a', 'code', 'strong', 'em' ] );
content = '<blockquote>' + content + "</blockquote>\n\n#slash-done";
content = '<blockquote>' + content + "</blockquote>\n\n#slash-done";
Loading