diff --git a/invenio_communities/subcommunities/services/service.py b/invenio_communities/subcommunities/services/service.py index 6e2762c21..4372421ae 100644 --- a/invenio_communities/subcommunities/services/service.py +++ b/invenio_communities/subcommunities/services/service.py @@ -155,7 +155,13 @@ def join(self, identity, id_, data, uow=None): @unit_of_work() def create_subcommunity_invitation_request( - self, identity, parent_community_id, child_community_id, data, uow=None + self, + identity, + parent_community_id, + child_community_id, + data, + expires_at=None, + uow=None, ): """Create and submit a SubCommunityInvitation request.""" type_ = current_request_type_registry.lookup( @@ -163,7 +169,9 @@ def create_subcommunity_invitation_request( ) parent_community = community_service.record_cls.pid.resolve(parent_community_id) child_community = community_service.record_cls.pid.resolve(child_community_id) - expires_at = datetime.now(timezone.utc) + timedelta(days=45) + + if not expires_at: + expires_at = datetime.now(timezone.utc) + timedelta(days=45) requests_service.create( identity=identity,