mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Show separate error messages for team key
Although using a team key is functionally the same as your service being restricted, conflating the two errors is not helpful. What we typically saw in research was that someone was using a team key, got the error, used a live key and got the _same_ error. This commit adds a new error message that specifically mentions the type of API key that you’re using.
This commit is contained in:
@@ -270,11 +270,15 @@ def send_notification(notification_type):
|
||||
[user.mobile_number, user.email_address] for user in service.users
|
||||
)
|
||||
):
|
||||
raise InvalidRequest(
|
||||
{'to': [(
|
||||
if (api_user.key_type == KEY_TYPE_TEAM):
|
||||
message = 'Can’t send to this recipient using a team-only API key'
|
||||
else:
|
||||
message = (
|
||||
'Can’t send to this recipient when service is in trial mode '
|
||||
'– see https://www.notifications.service.gov.uk/trial-mode'
|
||||
)]},
|
||||
)
|
||||
raise InvalidRequest(
|
||||
{'to': [message]},
|
||||
status_code=400
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user