From 03841693ba1536e8b7db52c366a6fb48d109b851 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 4 Aug 2020 20:09:42 +0200 Subject: [PATCH] Return support_pgp in GET /api/v2/aliases --- README.md | 1 + app/api/serializer.py | 1 + app/api/views/alias.py | 1 + tests/api/test_alias.py | 3 +++ 4 files changed, 6 insertions(+) diff --git a/README.md b/README.md index a80af265..c37709f6 100644 --- a/README.md +++ b/README.md @@ -964,6 +964,7 @@ If success, 200 with the list of aliases. Each alias has the following fields: - nb_block - nb_forward - nb_reply +- support_pgp: whether an alias can support PGP, i.e. when one of alias's mailboxes supports PGP. - mailbox: obsolete, should use `mailboxes` instead. - id - email diff --git a/app/api/serializer.py b/app/api/serializer.py index 8c2f85f9..635c157d 100644 --- a/app/api/serializer.py +++ b/app/api/serializer.py @@ -62,6 +62,7 @@ def serialize_alias_info_v2(alias_info: AliasInfo) -> dict: {"id": mailbox.id, "email": mailbox.email} for mailbox in alias_info.mailboxes ], + "support_pgp": alias_info.alias.mailbox_support_pgp() } if alias_info.latest_email_log: email_log = alias_info.latest_email_log diff --git a/app/api/views/alias.py b/app/api/views/alias.py index a21fbc61..3b0f96d4 100644 --- a/app/api/views/alias.py +++ b/app/api/views/alias.py @@ -84,6 +84,7 @@ def get_aliases_v2(): - note - mailbox - mailboxes + - support_pgp - (optional) latest_activity: - timestamp - action: forward|reply|block|bounced diff --git a/tests/api/test_alias.py b/tests/api/test_alias.py index 923213c2..6c98d702 100644 --- a/tests/api/test_alias.py +++ b/tests/api/test_alias.py @@ -187,6 +187,9 @@ def test_get_aliases_v2(flask_client): assert "id" in mailbox assert "email" in mailbox + assert "support_pgp" in r0 + assert not r0["support_pgp"] + def test_delete_alias(flask_client): user = User.create(