<commit_before>var express = require('express');
var router = express.Router();

router.get('/inbox', function(req, res) {
	req.getCredentials(function(error, credentials){
		if(error) res.status(500).json({ error: "Not Authenticated" });
		// Add better error handling here
		req.database.models.mail.find().where({ receiver: credentials.email, spamScore: { '<=': 5 } /* Spam filter */ }).exec(function(error, mails){
			if(error) res.status(500).json({ error: "Not Authenticated" });
			if((!mails)||(mails.length < 1)) mails = [];
			res.json({ mails: mails, request: { time: new Date() } });
		});
	});
});

module.exports = router;<commit_msg>Added filter for mail router<commit_after>var express = require('express');
var _ = require('lodash');
var router = express.Router();

router.get('/inbox', function(req, res) {
	req.getCredentials(function(error, credentials){
		if(error) res.status(500).json({ error: "Not Authenticated" });
		// Add better error handling here
		req.database.models.mail.find().where({ receiver: credentials.email, spamScore: { '<=': 5 } /* Spam filter */ }).exec(function(error, mails){
			if(error) res.status(500).json({ error: "Not Authenticated" });
			if((!mails)||(mails.length < 1)) mails = [];
			
			var filteredMails = _.pick(mails,['sender','receiver','to','stamp','subject','text','html','read']);
			res.json({ mails: filteredMails, request: { time: new Date() } });
		});
	});
});

module.exports = router;
{'fraction_non_alphanumeric': 0.20839064649243466, 'fraction_numerical': 0.011004126547455296, 'mean_word_length': 5.037344398340249, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7185608', 'n_tokens_mistral': 506, 'n_tokens_neox': 461, 'n_words': 102}