summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
diff options
context:
space:
mode:
authorroger <roger@elvex.org.ar>2013-02-09 11:28:21 -0300
committerroger <roger@elvex.org.ar>2013-02-09 11:34:46 -0300
commitbadd327360a0c33b5229edb733e38441e74774e8 (patch)
tree41fc0e98525446e15ac22d275d2c4cbeb8eb6e86 /sleekxmpp/plugins
parent9165cbf7f6839ee8ba2a4514b297f27fb019098a (diff)
downloadslixmpp-badd327360a0c33b5229edb733e38441e74774e8.tar.gz
slixmpp-badd327360a0c33b5229edb733e38441e74774e8.tar.bz2
slixmpp-badd327360a0c33b5229edb733e38441e74774e8.tar.xz
slixmpp-badd327360a0c33b5229edb733e38441e74774e8.zip
fixed gmail new mail notification check
without the tid gmail ignores the query
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r--sleekxmpp/plugins/gmail/notifications.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/sleekxmpp/plugins/gmail/notifications.py b/sleekxmpp/plugins/gmail/notifications.py
index dbc68162..53ad2f3f 100644
--- a/sleekxmpp/plugins/gmail/notifications.py
+++ b/sleekxmpp/plugins/gmail/notifications.py
@@ -46,6 +46,7 @@ class Gmail(BasePlugin):
self._handle_new_mail))
self._last_result_time = None
+ self._last_result_tid = None
def plugin_end(self):
self.xmpp.remove_handler('Gmail New Mail')
@@ -57,13 +58,19 @@ class Gmail(BasePlugin):
def check(self, block=True, timeout=None, callback=None):
last_time = self._last_result_time
- self._last_result_time = str(int(time.time() * 1000))
- return self.search(newer=last_time,
+ last_tid = self._last_result_tid
+ data = self.search(newer_time=last_time,
+ newer_tid=last_tid,
block=block,
timeout=timeout,
callback=callback)
- def search(self, query=None, newer=None, block=True,
+ 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
+
+ def search(self, query=None, newer_time=None, newer_tid=None, block=True,
timeout=None, callback=None):
if not query:
log.info('Gmail: Checking for new email')
@@ -73,5 +80,6 @@ class Gmail(BasePlugin):
iq['type'] = 'get'
iq['to'] = self.xmpp.boundjid.bare
iq['gmail']['search'] = query
- iq['gmail']['newer_than_time'] = newer
+ iq['gmail']['newer_than_time'] = newer_time
+ iq['gmail']['newer_than_tid'] = newer_tid
return iq.send(block=block, timeout=timeout, callback=callback)