Return pgp_enabled in GET /api/v2/aliases

This commit is contained in:
Son NK 2020-08-04 20:11:59 +02:00
parent 03841693ba
commit b3ca7d1d5b
4 changed files with 7 additions and 1 deletions

View File

@ -965,6 +965,7 @@ If success, 200 with the list of aliases. Each alias has the following fields:
- nb_forward
- nb_reply
- support_pgp: whether an alias can support PGP, i.e. when one of alias's mailboxes supports PGP.
- pgp_enabled: whether the PGP is enabled on this alias. This field should only be used when `support_pgp` is true.
- mailbox: obsolete, should use `mailboxes` instead.
- id
- email

View File

@ -62,7 +62,8 @@ 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()
"support_pgp": alias_info.alias.mailbox_support_pgp(),
"pgp_enabled": alias_info.alias.pgp_enabled()
}
if alias_info.latest_email_log:
email_log = alias_info.latest_email_log

View File

@ -85,6 +85,7 @@ def get_aliases_v2():
- mailbox
- mailboxes
- support_pgp
- pgp_enabled
- (optional) latest_activity:
- timestamp
- action: forward|reply|block|bounced

View File

@ -190,6 +190,9 @@ def test_get_aliases_v2(flask_client):
assert "support_pgp" in r0
assert not r0["support_pgp"]
assert "pgp_enabled" in r0
assert not r0["pgp_enabled"]
def test_delete_alias(flask_client):
user = User.create(