diff --git a/kibicara/platforms/email/webapi.py b/kibicara/platforms/email/webapi.py index 8f14165..305613c 100644 --- a/kibicara/platforms/email/webapi.py +++ b/kibicara/platforms/email/webapi.py @@ -33,6 +33,10 @@ class BodyEmail(BaseModel): return value +class BodyEmailPublic(BaseModel): + name: str + + class BodyMessage(BaseModel): """ This model shows which values are supplied by the MDA listener script. """ @@ -70,6 +74,18 @@ async def get_subscriber(subscriber_id: int, hood=Depends(get_hood)): router = APIRouter() +@router.get( + '/public', + # TODO response_model + operation_id='get_emails_public', +) +async def email_read_all_public(hood=Depends(get_hood_unauthorized)): + if hood.email_enabled: + emails = await Email.objects.filter(hood=hood).all() + return [BodyEmailPublic(name=email.name) for email in emails] + return [] + + @router.get( '/', # TODO response_model