Exemplo n.º 1
0
def send_stanza(stanza):
    """ Sends a stanza via profanity

    Ensures the stanza is valid XML before sending.
    """

    if xmpp.stanza_is_valid_xml(stanza):
        log.debug('Sending Stanza: {}'.format(stanza))
        prof.send_stanza(stanza)
        return True

    return False
def send_stanza(stanza):
    """ Sends a stanza via profanity

    Ensures the stanza is valid XML before sending.
    """

    if xmpp.stanza_is_valid_xml(stanza):
        log.debug('Sending Stanza: {}'.format(stanza))
        prof.send_stanza(stanza)
        return True

    return False
Exemplo n.º 3
0
def prof_on_message_stanza_send(stanza):
    stanza = ensure_unicode_stanza(stanza)

    contact_jid = xmpp.get_recipient(stanza)
    if not ProfActiveOmemoChats.account_is_active(contact_jid):
        log.debug('Chat not activated for {0}'.format(contact_jid))
        return None

    try:
        if xmpp.is_xmpp_plaintext_message(stanza):
            encrypted_stanza = xmpp.encrypt_stanza(stanza)
            if xmpp.stanza_is_valid_xml(encrypted_stanza):
                return encrypted_stanza
    except Exception as e:
        log.exception('Could not encrypt message')

    show_chat_critical(contact_jid, 'Last message was sent unencrypted.')
    return None
def prof_on_message_stanza_send(stanza):
    stanza = ensure_unicode_stanza(stanza)

    contact_jid = xmpp.get_recipient(stanza)
    if not ProfActiveOmemoChats.account_is_active(contact_jid):
        log.debug('Chat not activated for {0}'.format(contact_jid))
        return None

    try:
        if xmpp.is_xmpp_plaintext_message(stanza):
            encrypted_stanza = xmpp.encrypt_stanza(stanza)
            if xmpp.stanza_is_valid_xml(encrypted_stanza):
                return encrypted_stanza
    except Exception as e:
        log.exception('Could not encrypt message')

    show_chat_critical(contact_jid, 'Last message was sent unencrypted.')
    return None