diff --git a/src/server/BreCal/api/notifications.py b/src/server/BreCal/api/notifications.py index 4fe4a8e..c05d52e 100644 --- a/src/server/BreCal/api/notifications.py +++ b/src/server/BreCal/api/notifications.py @@ -12,12 +12,11 @@ bp = Blueprint('notifications', __name__) @auth_guard() # no restriction by role def GetNotifications(): try: - if 'shipcall_id' in request.args: - options = {} - options["shipcall_id"] = request.args.get("shipcall_id") - return impl.notifications.GetNotifications(options) + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') + return impl.notifications.GetNotifications(token) else: - return create_dynamic_exception_response(ex=None, status_code=400, message="missing argument: shipcall_id") - + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + except Exception as ex: return create_dynamic_exception_response(ex=ex, status_code=400) diff --git a/src/server/BreCal/impl/notifications.py b/src/server/BreCal/impl/notifications.py index 57fe62c..3a95e0a 100644 --- a/src/server/BreCal/impl/notifications.py +++ b/src/server/BreCal/impl/notifications.py @@ -6,21 +6,17 @@ from ..schemas import model from .. import local_db from BreCal.database.sql_queries import SQLQuery -def GetNotifications(options): +def GetNotifications(token): """ - :param options: A dictionary containing all the paramters for the Operations - options["shipcall_id"]: **Id**. *Example: 42*. Id of referenced ship call. - + No parameters, gets all entries """ try: pooledConnection = local_db.getPoolConnection() commands = pydapper.using(pooledConnection) - # query = SQLQuery.get_notifications() - # data = commands.query(query, model=model.Notification.from_query_row, param={"scid" : options["shipcall_id"]}) data = commands.query("SELECT id, shipcall_id, participant_id, level, type, message, created, modified FROM notification " + - "WHERE shipcall_id = ?scid?", model=model.Notification.from_query_row, param={"scid" : options["shipcall_id"]}) + "WHERE level = 2", model=model.Notification.from_query_row) pooledConnection.close() except Exception as ex: diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index 0d36fc8..f6de5c8 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -155,6 +155,7 @@ class Notification: return { "id": self.id, "shipcall_id": self.shipcall_id, + "participant_id": self.participant_id, "level": self.level, "type": self.type.name if isinstance(self.type, IntEnum) else NotificationType(self.type).name, "message": self.message,