Commits

Josh VanderLinden  committed 0177edf

Updating daemon to track messages, not just counts

  • Participants
  • Parent commits 9e2b442

Comments (0)

Files changed (2)

 # Maintainer: Josh VanderLinden <arch@cloudlery.com>
 pkgname=zedify
-pkgver=20130514
+pkgver=20130516
 pkgrel=1
 pkgdesc="Deliver message notifications to remote machines"
 arch=('any')

File zedify/remote.py

 class ZedifyDaemon:
 
     def __init__(self):
-        self.unseen = defaultdict(int)
+        self.unseen = defaultdict(list)
         self.log = get_logger('zedifyd')
 
         ctx = zmq.Context()
                 self.pub.send_json(msg)
 
                 self.log.info('Received message: {}'.format(msg))
-                ev = msg['event']
+                ev = msg.get('event', None)
                 handler = getattr(self, 'handle_{}'.format(ev), None)
                 if handler is not None:
                     handler(msg)
+                else:
+                    self.log.error('Unexpected message: {}'.format(msg))
 
                 self.send_status()
 
 
         self.pub.send_json({
             'event': 'current_status',
-            'unseen': {k: v for k, v in self.unseen.items() if v}
+            'unseen': {k: len(v) for k, v in self.unseen.items() if v}
         })
 
+        [self.pub.send_json(m)
+            for msgs in self.unseen.items()
+            for m in msgs]
+
     def handle_typing(self, msg):
         """Reset unseen count for the buffer we're typing into"""
 
-        self.unseen[msg['in_buffer']] = 0
+        self.unseen[msg['in_buffer']] = []
 
     def handle_buffer_switch(self, msg):
         """Reset unseen count for the buffer we're switching into"""
 
-        self.unseen[msg['to_buffer']] = 0
+        self.unseen[msg['to_buffer']] = []
 
     def handle_mention(self, msg):
         """Increment the unseen count for the buffer"""
     def handle_pm(self, msg):
         """Increment the unseen count for the buffer"""
 
-        self.unseen[msg['chat']] += 1
+        self.unseen[msg['chat']].append(msg)
 
 
 def main():