Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)