add filters to GET /notifications endpoints to only return for provided key_type

if api_key used to access endpoint is type team, endpoints only return that type -
will 404 if you provide a different ID. Same applies for normal (normal api keys
cannot see team notifications)
also, for convenience, set sample_notification to supply key_type of KEY_TYPE_NORMAL
by default
This commit is contained in:
Leo Hemsted
2016-06-30 18:43:15 +01:00
parent 01419e7894
commit 2cf1d22748
4 changed files with 214 additions and 91 deletions

View File

@@ -323,7 +323,9 @@ def sample_notification(notify_db,
created_at=datetime.utcnow(),
content_char_count=160,
create=True,
personalisation=None):
personalisation=None,
api_key_id=None,
key_type=KEY_TYPE_NORMAL):
if service is None:
service = sample_service(notify_db, notify_db_session)
if template is None:
@@ -352,7 +354,9 @@ def sample_notification(notify_db,
'created_at': created_at,
'content_char_count': content_char_count,
'personalisation': personalisation,
'notification_type': template.template_type
'notification_type': template.template_type,
'api_key_id': api_key_id,
'key_type': key_type
}
if job_row_number:
data['job_row_number'] = job_row_number