From 805f653e97b2c6e7ef1048b0ed7262d3c8261e15 Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Mon, 10 May 2021 11:52:06 +0200 Subject: [PATCH] Citadel: Compress very large access lists People who are in hundreds of groups otherwise can't search for anything because the request gets too large. Ideally Citadel accepted POST requests, but those are already used for data modifications, so we are stuck with GET for now. --- citadel/indico_citadel/search.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/citadel/indico_citadel/search.py b/citadel/indico_citadel/search.py index bb49392..9d7fc70 100644 --- a/citadel/indico_citadel/search.py +++ b/citadel/indico_citadel/search.py @@ -5,6 +5,9 @@ # them and/or modify them under the terms of the MIT License; # see the LICENSE file for more details. +import base64 +import zlib + import requests from requests.exceptions import RequestException from werkzeug.urls import url_join @@ -46,7 +49,12 @@ class CitadelProvider(IndicoSearchProvider): **filter_query} # Filter by the objects that can be viewed by users/groups in the `access` argument if access: - search_params['access'] = ','.join(access) + access_string = ','.join(access) + if len(access_string) > 1024: + access_string_gz = base64.b64encode(zlib.compress(access_string.encode(), level=9)) + search_params['access_gz'] = access_string_gz + else: + search_params['access'] = access_string try: resp = requests.get(self.records_url, params=search_params, headers=headers)