[email] Add public email endpoint to list all bots to a hood

This commit is contained in:
Cathy Hu 2020-09-03 17:37:03 +02:00
parent 5575782b9b
commit d8c138982d

View file

@ -33,6 +33,10 @@ class BodyEmail(BaseModel):
return value return value
class BodyEmailPublic(BaseModel):
name: str
class BodyMessage(BaseModel): class BodyMessage(BaseModel):
""" This model shows which values are supplied by the MDA listener script. """ """ 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 = 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( @router.get(
'/', '/',
# TODO response_model # TODO response_model