From d8c138982d816a2347720d2ebfde105f4bf9acd3 Mon Sep 17 00:00:00 2001 From: Cathy Hu Date: Thu, 3 Sep 2020 17:37:03 +0200 Subject: [PATCH] [email] Add public email endpoint to list all bots to a hood --- kibicara/platforms/email/webapi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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