diff options
Diffstat (limited to 'sleekxmpp')
-rw-r--r-- | sleekxmpp/plugins/gmail/notifications.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sleekxmpp/plugins/gmail/notifications.py b/sleekxmpp/plugins/gmail/notifications.py index 53ad2f3f..9cc67f04 100644 --- a/sleekxmpp/plugins/gmail/notifications.py +++ b/sleekxmpp/plugins/gmail/notifications.py @@ -59,16 +59,20 @@ class Gmail(BasePlugin): def check(self, block=True, timeout=None, callback=None): last_time = self._last_result_time last_tid = self._last_result_tid - data = self.search(newer_time=last_time, + + def check_callback(data): + self._last_result_time = data["gmail_messages"]["result_time"] + if data["gmail_messages"]["threads"]: + self._last_result_tid = \ + data["gmail_messages"]["threads"][0]["tid"] + if callback: + callback(data) + + return self.search(newer_time=last_time, newer_tid=last_tid, block=block, timeout=timeout, - callback=callback) - - self._last_result_time = data["gmail_messages"]["result_time"] - if data["gmail_messages"]["threads"]: - self._last_result_tid = data["gmail_messages"]["threads"][0]["tid"] - return data + callback=check_callback) def search(self, query=None, newer_time=None, newer_tid=None, block=True, timeout=None, callback=None): |