Commits

Alexander Shorin committed 4e2417f

Add missing presence support for SleekXMPP server.

  • Participants
  • Parent commits e91cdc9

Comments (0)

Files changed (1)

xmppflask/server.py

 
         self.client.add_event_handler('session_start', self.on_start)
         self.client.add_event_handler('message', self.handle_message)
-        self.client.add_event_handler('presence', self.handle_presence)
+        presences = ['available', 'unavailable', 'probe', 'error',
+                     'dnd', 'xa', 'chat', 'away']
+        for presence in presences:
+            self.client.add_event_handler('presence_%s' % presence,
+                                          self.handle_presence)
 
     def on_start(self, *args, **kwargs):
         self.client.send_presence()
             environ['subject'] = maybe_unicode(event['subject'])
             environ['mucroom'] = maybe_unicode(event['mucroom'])
             environ['mucnick'] = maybe_unicode(event['mucnick'])
+        elif isinstance(event, self.presence_class):
+            environ['priority'] = maybe_unicode(event['priority'])
+            environ['status'] = maybe_unicode(event['status'])
+            environ['type'] = maybe_unicode(environ['type'] or event['show'])
 
         return environ