| OLD | NEW | 
|---|
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, | 
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH | 
| 3 # | 3 # | 
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify | 
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as | 
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. | 
| 7 # | 7 # | 
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, | 
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93         if 'variants' in notification: | 93         if 'variants' in notification: | 
| 94             notification = copy.deepcopy(notification) | 94             notification = copy.deepcopy(notification) | 
| 95             del notification['variants'] | 95             del notification['variants'] | 
| 96         notifications_to_send.append(notification) | 96         notifications_to_send.append(notification) | 
| 97     return notifications_to_send | 97     return notifications_to_send | 
| 98 | 98 | 
| 99 | 99 | 
| 100 def _create_response(notifications, groups): | 100 def _create_response(notifications, groups): | 
| 101     return { | 101     return { | 
| 102         'version': _generate_version(groups), | 102         'version': _generate_version(groups), | 
| 103         'notifications': _get_notifications_to_send(notifications, groups) | 103         'notifications': _get_notifications_to_send(notifications, groups), | 
| 104     } | 104     } | 
| 105 | 105 | 
| 106 | 106 | 
| 107 @url_handler('/notification.json') | 107 @url_handler('/notification.json') | 
| 108 def notification(environ, start_response): | 108 def notification(environ, start_response): | 
| 109     params = urlparse.parse_qs(environ.get('QUERY_STRING', '')) | 109     params = urlparse.parse_qs(environ.get('QUERY_STRING', '')) | 
| 110     version = params.get('lastVersion', [''])[0] | 110     version = params.get('lastVersion', [''])[0] | 
| 111     notifications = load_notifications() | 111     notifications = load_notifications() | 
| 112     groups = _determine_groups(version, notifications) | 112     groups = _determine_groups(version, notifications) | 
| 113     notifications = [x for x in notifications if not x.get('inactive', False)] | 113     notifications = [x for x in notifications if not x.get('inactive', False)] | 
| 114     _assign_groups(groups, notifications) | 114     _assign_groups(groups, notifications) | 
| 115     response = _create_response(notifications, groups) | 115     response = _create_response(notifications, groups) | 
| 116     response_headers = [('Content-Type', 'application/json; charset=utf-8'), | 116     response_headers = [('Content-Type', 'application/json; charset=utf-8'), | 
| 117                         ('ABP-Notification-Version', response['version'])] | 117                         ('ABP-Notification-Version', response['version'])] | 
| 118     response_body = json.dumps(response, ensure_ascii=False, indent=2, | 118     response_body = json.dumps(response, ensure_ascii=False, indent=2, | 
| 119                                separators=(',', ': '), | 119                                separators=(',', ': '), | 
| 120                                sort_keys=True).encode('utf-8') | 120                                sort_keys=True).encode('utf-8') | 
| 121     start_response('200 OK', response_headers) | 121     start_response('200 OK', response_headers) | 
| 122     return response_body | 122     return response_body | 
| OLD | NEW | 
|---|