Handles presence stanzas

def on_presence(self, session, presence):
        """Handles presence stanzas"""
        from_jid = presence.getFrom()
        is_member = self.is_member(from_jid.getStripped())
        if is_member:
            member = self.get_member(from_jid.getStripped())
        else:
            member = None

        logger.info('presence: from=%s is_member=%s type=%s' % (from_jid, is_member, presence.getType()))

        if presence.getType() == 'subscribed':
            if is_member:
                logger.info('[%s] accepted their invitation' % (from_jid,))
                member['STATUS'] = 'ACTIVE'
            else:
                #TODO: user accepted, but is no longer be on the roster, unsubscribe?
                pass
        elif presence.getType() == 'subscribe':
            if is_member:
                logger.info('Acknowledging subscription request from [%s]' % (from_jid,))
                self.client.sendPresence(jid=from_jid, typ='subscribed')
                member['STATUS'] = 'ACTIVE'
                self.broadcast('%s has accepted their invitation!' % (from_jid,))
            else:
                #TODO: show that a user has requested membership?
                pass
        elif presence.getType() == None:
            if is_member:
                member['ONLINE'] += 1
        elif presence.getType() == 'unavailable':
            if is_member:
                member['ONLINE'] -= 1
        else:
            logger.info('Unhandled presence stanza of type [%s] from [%s]' % (presence.getType(), from_jid))