diff --git a/src/app/domain/companies/controllers/companies.py b/src/app/domain/companies/controllers/companies.py index ba0b7d54..319df02b 100644 --- a/src/app/domain/companies/controllers/companies.py +++ b/src/app/domain/companies/controllers/companies.py @@ -54,7 +54,9 @@ async def list_companies( ) # Workaround due to https://github.com/jcrist/msgspec/issues/673 for company in paginated_response.items: - company.profile_pic_url = get_logo_dev_link(company.url) + if company.url: + company.profile_pic_url = get_logo_dev_link(company.url) + return paginated_response @post( @@ -93,8 +95,11 @@ async def get_company( """Get details about a comapny.""" db_obj = await companies_service.get(company_id) company = companies_service.to_schema(schema_type=Company, data=db_obj) + # Workaround due to https://github.com/jcrist/msgspec/issues/673 - company.profile_pic_url = get_logo_dev_link(company.url) + if company.url: + company.profile_pic_url = get_logo_dev_link(company.url) + return company @patch( diff --git a/src/app/domain/opportunities/controllers/opportunities.py b/src/app/domain/opportunities/controllers/opportunities.py index 90a66ac6..8cb7de24 100644 --- a/src/app/domain/opportunities/controllers/opportunities.py +++ b/src/app/domain/opportunities/controllers/opportunities.py @@ -9,6 +9,7 @@ from litestar.exceptions import ValidationException from app.config import constants +from app.lib.utils import get_logo_dev_link from app.db.models import User as UserModel from app.domain.accounts.guards import requires_active_user from app.domain.accounts.dependencies import provide_users_service @@ -58,7 +59,16 @@ async def list_opportunities( ) -> OffsetPagination[Opportunity]: """List opportunities that your account can access..""" results, total = await opportunities_service.get_opportunities(*filters, tenant_id=current_user.tenant_id) - return opportunities_service.to_schema(data=results, total=total, schema_type=Opportunity, filters=filters) + paginated_response = opportunities_service.to_schema( + data=results, total=total, schema_type=Opportunity, filters=filters + ) + + # Workaround due to https://github.com/jcrist/msgspec/issues/673 + for opportunity in paginated_response.items: + if opportunity.company and opportunity.company.url: + opportunity.company.profile_pic_url = get_logo_dev_link(opportunity.company.url) + + return paginated_response @post( operation_id="CreateOpportunity", @@ -119,7 +129,13 @@ async def get_opportunity( ) -> Opportunity: """Get details about a comapny.""" db_obj = await opportunities_service.get_opportunity(opportunity_id, tenant_id=current_user.tenant_id) - return opportunities_service.to_schema(schema_type=Opportunity, data=db_obj) + opportunity = opportunities_service.to_schema(schema_type=Opportunity, data=db_obj) + + # Workaround due to https://github.com/jcrist/msgspec/issues/673 + if opportunity.company and opportunity.company.url: + opportunity.company.profile_pic_url = get_logo_dev_link(opportunity.company.url) + + return opportunity @patch( operation_id="UpdateOpportunity",