From d86122ae8eecc899f643d9490bab362e64f65caa Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Fri, 12 Jan 2024 09:38:26 +0100 Subject: [PATCH] fix: permission problem * it is better to check in the handling function if the record is public or not. with this approach it applies to all datamodels and drafts and records. * this change was primarly necessary for the database rebuild feature --- invenio_global_search/components.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/invenio_global_search/components.py b/invenio_global_search/components.py index b68396b..e93dd40 100644 --- a/invenio_global_search/components.py +++ b/invenio_global_search/components.py @@ -43,6 +43,10 @@ def map_metadata_from_a_to_b( record_serializer = serializer_cls() data = record.dumps() + + if data["access"]["record"] != "public": + return + obj = metadata_cls(json=data["metadata"]) if metadata_cls else data metadata = record_serializer.dump_obj(obj) pid = record["id"] @@ -148,9 +152,6 @@ def publish( **_: dict, ) -> None: """Create handler.""" - if draft["access"]["record"] != "public": - return - cmp_op = ComponentOp( record, serializer_cls=DublinCoreJSONSerializer,