lib/slackutil.js
/**
     * @brief Middeware function to validate the POST request body. This
     *        function checks if Slack is sending all the required properties
     *        for the /ttt slash command. An error is sent if it is invalid.
     *
     * @param req express http request object
     * @param res express http response object
     * @param next express middleware next function
     *
     * @return none
     */
@brief Middeware function to validate the POST request body. This
function checks if Slack is sending all the required properties
for the /ttt slash command. An error is sent if it is invalid.

@param req express http request object
@param res express http response object
@param next express middleware next function

@return none
@brief Middeware function to validate the POST request body . This function checks if Slack is sending all the required properties for the / ttt slash command . An error is sent if it is invalid . @param req express http request object @param res express http response object @param next express middleware next function @return none
function checkPostBody(req, res, next) {
        if (req.method !== "POST") {
            next();
        }
        let body = req.body;
        logger.trace({requestBody: req.body}, "Checking POST body.");
        if (body === undefined || body === null) {
            return res.status(400).end("Incorrect Post Body!");
        }
        if (
            body.channel_id === undefined
                || body.channel_name === undefined
                || body.team_id === undefined
                || body.user_name === undefined
                || body.user_id === undefined
                || body.text === undefined
                || body.token === undefined
                || body.command === undefined
                || body.command !== "/" + constants.comandName
        ) {
            return res.status(400).end("Incorrect Post Body!");
        }
        next();
    }
function checkPostBody ( req , res , next ) { if ( req . method !== "POST" ) { next ( ) ; } let body = req . body ; logger . trace ( { requestBody : req . body } , "Checking POST body." ) ; if ( body === undefined || body === null ) { return res . status ( 400 ) . end ( "Incorrect Post Body!" ) ; } if ( body . channel_id === undefined || body . channel_name === undefined || body . team_id === undefined || body . user_name === undefined || body . user_id === undefined || body . text === undefined || body . token === undefined || body . command === undefined || body . command !== "/" + constants . comandName ) { return res . status ( 400 ) . end ( "Incorrect Post Body!" ) ; } next ( ) ; }
@brief Middeware function to validate the POST request body.
@brief Middeware function to validate the POST request body .
// Check if body is available. // Check if the body properties are available.