<commit_before>var Promise = require('promise');
var _ = require('lodash');
var winston = require('winston');
var MongoClient = require('mongodb').MongoClient;

var config = require('./config');
var AttributesService = require('../shared/attributes').AttributesService;

var apiPhotoBase = '/api/photos/';
var expectedKeys = ['type', 'asset', 'data'];

function photoIdFromURL(photoUrl) {
  return photoUrl.slice(apiPhotoBase.length);
}

var basicValidations = [
  function (event) { return expectedKeys.length === _.intersection(expectedKeys, _.keys(event)).length; },
  function (event) { return _.includes(['edit-photo'], event.type); },
  function (event) { return event.asset.indexOf(apiPhotoBase) === 0; },
  function (event) { return event.asset.split('/').length === 4; },
  function (event) { return _.isArray(event.data); },
  function (event) { return _.isEmpty(AttributesService.create().errors(event.data)); }
];

module.exports = {
  validate: function (event) {
    return Promise.resolve(_.every(basicValidations, function (validation) { return validation(event); }))
      .then(function (result) {
        return result ? require('./media').read(event.asset) : false;
      }, function () { return false; })
      .then(function(result) {
        return !!result;
      }, function () { return false; });
  },<commit_msg>Removing dead code.<commit_after>var Promise = require('promise');
var _ = require('lodash');
var winston = require('winston');
var MongoClient = require('mongodb').MongoClient;

var config = require('./config');
var AttributesService = require('../shared/attributes').AttributesService;

var apiPhotoBase = '/api/photos/';
var expectedKeys = ['type', 'asset', 'data'];

var basicValidations = [
  function (event) { return expectedKeys.length === _.intersection(expectedKeys, _.keys(event)).length; },
  function (event) { return _.includes(['edit-photo'], event.type); },
  function (event) { return event.asset.indexOf(apiPhotoBase) === 0; },
  function (event) { return event.asset.split('/').length === 4; },
  function (event) { return _.isArray(event.data); },
  function (event) { return _.isEmpty(AttributesService.create().errors(event.data)); }
];

module.exports = {
  validate: function (event) {
    return Promise.resolve(_.every(basicValidations, function (validation) { return validation(event); }))
      .then(function (result) {
        return result ? require('./media').read(event.asset) : false;
      }, function () { return false; })
      .then(function(result) {
        return !!result;
      }, function () { return false; });
  },
{'fraction_non_alphanumeric': 0.17699115044247787, 'fraction_numerical': 0.0015390534821085034, 'mean_word_length': 4.520169851380042, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2980746', 'n_tokens_mistral': 744, 'n_tokens_neox': 731, 'n_words': 168}