From 8a18ad2c35ca6f33793bf5db6186bbdf09ed6068 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Sun, 23 Apr 2017 16:27:15 +0200 Subject: [PATCH] Fetching notifications works again, fixes #31 --- diaspy/models.py | 2 +- diaspy/notifications.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/diaspy/models.py b/diaspy/models.py index 8371194..c58f38b 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -148,7 +148,7 @@ class Notification(): def __init__(self, connection, data): self._connection = connection - self.type = list(data.keys())[0] + self.type = data['type'] self._data = data[self.type] self.id = self._data['id'] self.unread = self._data['unread'] diff --git a/diaspy/notifications.py b/diaspy/notifications.py index bfcfada..8393c75 100644 --- a/diaspy/notifications.py +++ b/diaspy/notifications.py @@ -15,6 +15,7 @@ class Notifications(): """ def __init__(self, connection): self._connection = connection + self._data = {} self._notifications = self.get() def __iter__(self): @@ -47,4 +48,6 @@ class Notifications(): raise Exception('status code: {0}: cannot retreive notifications'.format(request.status_code)) notifications = request.json() - return [Notification(self._connection, n) for n in notifications] + self._data['unread_count'] = notifications['unread_count'] + self._data['unread_count_by_type'] = notifications['unread_count_by_type'] + return [Notification(self._connection, n) for n in notifications.get('notification_list', [])] -- 2.25.1