Add local time/date and devcie name conversions to alert email.
This commit is contained in:
		
							parent
							
								
									722fb44f7c
								
							
						
					
					
						commit
						2a897e0bef
					
				@ -11,3 +11,15 @@ exports.getLocDateFromUTC = function(utcDtTm) {
 | 
			
		||||
    localDt = moment(localDt).tz('America/New_York').format('MM-DD-YYYY');
 | 
			
		||||
    return localDt;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.getCoreNameFromCoreId = function(db, coreId) {
 | 
			
		||||
    db.all('SELECT coreName FROM Cores WHERE coreId = ? LIMIT 1;', coreId, function(err, rows){
 | 
			
		||||
        if (err !== null) {
 | 
			
		||||
            console.log(err);
 | 
			
		||||
        } else {
 | 
			
		||||
            return rows.coreName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -176,9 +176,6 @@ app.get('/core/:id', function(req, res){
 | 
			
		||||
 | 
			
		||||
            // Loop over elements in rows array, convert ugly UTC times to pretty local times.
 | 
			
		||||
            rows.forEach(function(row){
 | 
			
		||||
                //var localDtTm = moment.utc(new Date(row.published_at));
 | 
			
		||||
                //localDtTm = moment(localDtTm).tz('America/New_York').format('MM-DD-YYYY HH:mm:ss');
 | 
			
		||||
                //row.published_at = localDtTm;
 | 
			
		||||
                row.pubDate = alertmonUtils.getLocDateFromUTC(row.published_at);
 | 
			
		||||
                row.pubTime = alertmonUtils.getLocTimeFromUTC(row.published_at);
 | 
			
		||||
            });
 | 
			
		||||
@ -188,7 +185,6 @@ app.get('/core/:id', function(req, res){
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    //res.send;
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
app.post('/', function(req, res){
 | 
			
		||||
@ -213,8 +209,8 @@ app.post('/', function(req, res){
 | 
			
		||||
    if(status.toLowerCase().indexOf('alert') > -1){
 | 
			
		||||
        mailOptions.text = 'An alert message was received: \n\n';
 | 
			
		||||
        mailOptions.text = mailOptions.text + 'Status message, ' + status + '\n';
 | 
			
		||||
        mailOptions.text = mailOptions.text + 'Published at, ' + pubAt + '\n';
 | 
			
		||||
        mailOptions.text = mailOptions.text + 'From device, ' + coreid + '\n';
 | 
			
		||||
        mailOptions.text = mailOptions.text + 'Published at, ' + alertmonUtils.getLocDateFromUTC(pubAt) + ' ' + alertmonUtils.getLocTimeFromUTC(pubAt) + '\n';
 | 
			
		||||
        mailOptions.text = mailOptions.text + 'From device, ' + alertmonUtils.getCoreNameFromCoreId(coreid) + '\n';
 | 
			
		||||
 | 
			
		||||
        transporter.sendMail(mailOptions, function(error, info){
 | 
			
		||||
            if(error){
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user