mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
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.
This commit is contained in:
parent
8d655a8dce
commit
805f653e97
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user