diff --git a/invenio_rdm_records/requests/community_inclusion.py b/invenio_rdm_records/requests/community_inclusion.py index 9735ea49e..b9f32adc0 100644 --- a/invenio_rdm_records/requests/community_inclusion.py +++ b/invenio_rdm_records/requests/community_inclusion.py @@ -48,7 +48,7 @@ def execute(self, identity, uow): class AcceptAction(actions.AcceptAction): """Accept action.""" - def execute(self, identity, uow): + def execute(self, identity, uow, **kwargs): """Include record into community.""" # Resolve the topic and community - the request type only allow for # community receivers and record topics. @@ -79,13 +79,15 @@ def execute(self, identity, uow): # not be immediately visible in the community's records, when the `all versions` # facet is not toggled uow.register(RecordIndexOp(record, indexer=service.indexer, index_refresh=True)) - uow.register( - NotificationOp( - CommunityInclusionAcceptNotificationBuilder.build( - identity=identity, request=self.request + + if kwargs.get("send_notification", True): + uow.register( + NotificationOp( + CommunityInclusionAcceptNotificationBuilder.build( + identity=identity, request=self.request + ) ) ) - ) super().execute(identity, uow) diff --git a/invenio_rdm_records/requests/community_submission.py b/invenio_rdm_records/requests/community_submission.py index 070a0399c..fb3d1444d 100644 --- a/invenio_rdm_records/requests/community_submission.py +++ b/invenio_rdm_records/requests/community_submission.py @@ -8,7 +8,6 @@ """Community submission request.""" -from invenio_access.permissions import system_identity from invenio_drafts_resources.services.records.uow import ParentRecordCommitOp from invenio_i18n import lazy_gettext as _ from invenio_notifications.services.uow import NotificationOp @@ -44,7 +43,7 @@ def execute(self, identity, uow): class AcceptAction(actions.AcceptAction): """Accept action.""" - def execute(self, identity, uow): + def execute(self, identity, uow, **kwargs): """Accept record into community.""" # Resolve the topic and community - the request type only allow for # community receivers and record topics. @@ -83,8 +82,7 @@ def execute(self, identity, uow): # TODO: Ensure that the accepting user has permissions to publish. service.publish(identity, draft.pid.pid_value, uow=uow) - # don't send notification about request auto-accept - if identity != system_identity: + if kwargs.get("send_notification", True): uow.register( NotificationOp( CommunityInclusionAcceptNotificationBuilder.build( @@ -92,6 +90,7 @@ def execute(self, identity, uow): ) ) ) + super().execute(identity, uow) diff --git a/invenio_rdm_records/services/community_inclusion/service.py b/invenio_rdm_records/services/community_inclusion/service.py index b74056dfc..8eed5bbc5 100644 --- a/invenio_rdm_records/services/community_inclusion/service.py +++ b/invenio_rdm_records/services/community_inclusion/service.py @@ -63,7 +63,12 @@ def include(self, identity, community, request, uow): if can_include_directly: request_item = current_requests_service.execute_action( - system_identity, request.id, "accept", data=None, uow=uow + system_identity, + request.id, + "accept", + data=None, + uow=uow, + send_notification=False, ) data = {