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

@@ -171,7 +171,9 @@ def process_firetext_response():
@notifications.route('/notifications/<uuid:notification_id>', methods=['GET'])
def get_notifications(notification_id):
notification = notifications_dao.get_notification(str(api_user.service_id), notification_id)
notification = notifications_dao.get_notification(str(api_user.service_id),
notification_id,
key_type=api_user.key_type)
return jsonify(data={"notification": notification_status_schema.dump(notification).data}), 200
@@ -187,7 +189,8 @@ def get_all_notifications():
filter_dict=data,
page=page,
page_size=page_size,
limit_days=limit_days)
limit_days=limit_days,
key_type=api_user.key_type)
return jsonify(
notifications=notification_status_schema.dump(pagination.items, many=True).data,
page_size=page_size,