diff --git a/src/backend/core/services/converter_services.py b/src/backend/core/services/converter_services.py index 91dd6e5d..e6c28fe2 100644 --- a/src/backend/core/services/converter_services.py +++ b/src/backend/core/services/converter_services.py @@ -25,7 +25,7 @@ class ServiceUnavailableError(ConversionError): class ConverterProtocol(typing.Protocol): """Protocol for converter classes.""" - def convert(self, text, content_type, accept): + def convert(self, data, content_type, accept): """Convert content from one format to another.""" @@ -43,10 +43,11 @@ class Converter: """Convert input into other formats using external microservices.""" if content_type == mime_types.DOCX and accept == mime_types.YJS: - return self.convert( - self.docspec.convert(data, mime_types.DOCX, mime_types.BLOCKNOTE), - mime_types.BLOCKNOTE, - mime_types.YJS, + blocknote_data = self.docspec.convert( + data, mime_types.DOCX, mime_types.BLOCKNOTE + ) + return self.ydoc.convert( + blocknote_data, mime_types.BLOCKNOTE, mime_types.YJS ) return self.ydoc.convert(data, content_type, accept) @@ -111,16 +112,16 @@ class YdocConverter: response.raise_for_status() return response - def convert(self, text, content_type=mime_types.MARKDOWN, accept=mime_types.YJS): + def convert(self, data, content_type=mime_types.MARKDOWN, accept=mime_types.YJS): """Convert a Markdown text into our internal format using an external microservice.""" - if not text: - raise ValidationError("Input text cannot be empty") + if not data: + raise ValidationError("Input data cannot be empty") try: response = self._request( f"{settings.Y_PROVIDER_API_BASE_URL}{settings.CONVERSION_API_ENDPOINT}/", - text, + data, content_type, accept, ) diff --git a/src/backend/core/tests/test_services_converter_services.py b/src/backend/core/tests/test_services_converter_services.py index 5cb9a4b1..760504ce 100644 --- a/src/backend/core/tests/test_services_converter_services.py +++ b/src/backend/core/tests/test_services_converter_services.py @@ -22,9 +22,9 @@ def test_auth_header(settings): def test_convert_empty_text(): - """Should raise ValidationError when text is empty.""" + """Should raise ValidationError when data is empty.""" converter = YdocConverter() - with pytest.raises(ValidationError, match="Input text cannot be empty"): + with pytest.raises(ValidationError, match="Input data cannot be empty"): converter.convert("") @@ -143,5 +143,5 @@ def test_convert_none_input(): """Should raise ValidationError when input is None.""" converter = YdocConverter() - with pytest.raises(ValidationError, match="Input text cannot be empty"): + with pytest.raises(ValidationError, match="Input data cannot be empty"): converter.convert(None) diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index 07a5182a..64ffed97 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -1057,6 +1057,9 @@ class Production(Base): # Privacy SECURE_REFERRER_POLICY = "same-origin" + # Conversion API: Always verify SSL in production + CONVERSION_API_SECURE = True + CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache",