Let team key send to whitelist

There is an overlap between team key/trial mode/whitelist. But it’s not
a complete overlap. So it’s hard to understand all the different
permutations of which key lets you send to which people when.

This commit tries to reduce the differences between these concepts. So
for a user of the API

**In trial mode**

- You can send to anyone in your team or whitelist, using the team key
- You can simulate sending to anyone, using the simulate key

**When you’re live**

- You can send to anyone in your team or whitelist, using the team key
- You can simulate sending to anyone, using the simulate key
- You can send to anyone with the live key

So doing a `git diff` on that list, the only difference between being in
trial mode and live mode is now:

`+` You can send to anyone with the live key

**(How trial mode used to work)**
- You can send to anyone in your team or whitelist, using the normal key
- You can simulate sending to anyone, using the simulate key
- You can send to _just_ people in your team using the team key
This commit is contained in:
Chris Hill-Scott
2016-10-07 15:38:36 +01:00
parent b9ac337c68
commit 74be99e7c7
2 changed files with 34 additions and 23 deletions

View File

@@ -34,16 +34,16 @@ def service_allowed_to_send_to(recipient, service, key_type):
return True
team_members = itertools.chain.from_iterable(
[user.mobile_number, user.email_address] for user in service.users)
[user.mobile_number, user.email_address] for user in service.users
)
whitelist_members = [
member.recipient for member in service.whitelist
]
if key_type == KEY_TYPE_TEAM:
return allowed_to_send_to(
recipient,
team_members
)
if key_type == KEY_TYPE_NORMAL and service.restricted:
whitelist_members = [member.recipient for member in service.whitelist]
if (
(key_type == KEY_TYPE_NORMAL and service.restricted) or
(key_type == KEY_TYPE_TEAM)
):
return allowed_to_send_to(
recipient,
itertools.chain(