diff --git a/sanitiser/_warn_quattroshapes.js b/sanitiser/_warn_quattroshapes.js new file mode 100644 index 00000000..b4486cfe --- /dev/null +++ b/sanitiser/_warn_quattroshapes.js @@ -0,0 +1,25 @@ +var _ = require('lodash'); + +function setup( paramName, targetMap ) { + return function( raw, clean ){ + return sanitize( raw, clean ); + }; +} + +function sanitize( raw, clean, opts ) { + // error & warning messages + var messages = { errors: [], warnings: [] }; + + if (_.includes(raw.sources, 'quattroshapes') || _.includes(raw.sources, 'qs')) { + messages.warnings.push( 'You are using Quattroshapes as a data source in this query. ' + + 'Quattroshapes will be disabled as a data source for Mapzen Search in the next several ' + + 'weeks, and is being replaced by Who\'s on First, an actively maintained data project ' + + 'based on Quattroshapes. Your existing queries WILL CONTINUE TO WORK for the foreseeable ' + + 'future, but results will be coming from Who\'s on First and `source=quattroshapes` will ' + + 'be deprecated. If you have any questions, please email search@mapzen.com.'); + } + + return messages; +} + +module.exports = setup; diff --git a/sanitiser/reverse.js b/sanitiser/reverse.js index 154fd3d9..6ebcfd14 100644 --- a/sanitiser/reverse.js +++ b/sanitiser/reverse.js @@ -5,6 +5,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'), singleScalarParameters: require('../sanitiser/_single_scalar_parameters'), layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type), sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type), + quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(), size: require('../sanitiser/_size'), private: require('../sanitiser/_flag_bool')('private', false), geo_reverse: require('../sanitiser/_geo_reverse'), diff --git a/sanitiser/search.js b/sanitiser/search.js index cc596b26..75be20ca 100644 --- a/sanitiser/search.js +++ b/sanitiser/search.js @@ -7,6 +7,7 @@ var sanitizeAll = require('../sanitiser/sanitizeAll'), size: require('../sanitiser/_size'), layers: require('../sanitiser/_targets')('layers', type_mapping.layer_with_aliases_to_type), sources: require('../sanitiser/_targets')('sources', type_mapping.source_to_type), + quattroshapes_warning: require('../sanitiser/_warn_quattroshapes')(), private: require('../sanitiser/_flag_bool')('private', false), geo_search: require('../sanitiser/_geo_search'), boundary_country: require('../sanitiser/_boundary_country'), diff --git a/test/unit/sanitiser/reverse.js b/test/unit/sanitiser/reverse.js index 4e727b5b..d9fdebc9 100644 --- a/test/unit/sanitiser/reverse.js +++ b/test/unit/sanitiser/reverse.js @@ -38,7 +38,8 @@ module.exports.tests.interface = function(test, common) { module.exports.tests.sanitisers = function(test, common) { test('check sanitiser list', function (t) { - var expected = ['singleScalarParameters', 'layers', 'sources', 'size', 'private', 'geo_reverse', 'boundary_country']; + var expected = [ 'singleScalarParameters', 'layers', 'sources', 'quattroshapes_warning', + 'size', 'private', 'geo_reverse', 'boundary_country' ]; t.deepEqual(Object.keys(reverse.sanitiser_list), expected); t.end(); }); diff --git a/test/unit/sanitiser/search.js b/test/unit/sanitiser/search.js index b00160dd..07178626 100644 --- a/test/unit/sanitiser/search.js +++ b/test/unit/sanitiser/search.js @@ -24,7 +24,8 @@ module.exports.tests.interface = function(test, common) { module.exports.tests.sanitisers = function(test, common) { test('check sanitiser list', function (t) { - var expected = ['singleScalarParameters', 'text', 'size', 'layers', 'sources', 'private', 'geo_search', 'boundary_country' ]; + var expected = [ 'singleScalarParameters', 'text', 'size', 'layers', 'sources', + 'quattroshapes_warning', 'private', 'geo_search', 'boundary_country' ]; t.deepEqual(Object.keys(search.sanitiser_list), expected); t.end(); });