def list_jids(): """View to list the subscribed JIDs. Admin only. """ jids = [person.jid.address for person in JIDPerson.all()] return dict(author=AUTHOR, email=EMAIL, jids=jids)
def save_jid(jid): """Save JID only if it does not already exist.""" query = JIDPerson.all() query.filter('jid =', create_im(jid)) if not query.get(): p = JIDPerson(jid=create_im(jid)) logging.info("Subscribe %s" % jid) p.put()
def post_msg(): """Handle new messages. Send the message to all subscribes JIDs. """ jids = [person.jid.address for person in JIDPerson.all()] msg = request.forms.get('msg') for jid in jids: xmpp.send_message(jid, msg) logging.info('Send msg: %s' % msg) return dict(author=AUTHOR, email=EMAIL, sent=True)