Beispiel #1
0
    def process_incoming(self, user=None):
        from pyaspora.diaspora.actions import process_incoming_message

        dmp = DiasporaMessageParser(DiasporaContact.get_by_username)
        ret, c_from = dmp.decode(self.body.decode('ascii'),
                                 user._unlocked_key if user else None)
        process_incoming_message(ret, c_from, user)
Beispiel #2
0
    def process_incoming(self, user=None):
        from pyaspora.diaspora.actions import process_incoming_message

        dmp = DiasporaMessageParser(DiasporaContact.get_by_username)
        ret, c_from = dmp.decode(
            self.body.decode('ascii'),
            user._unlocked_key if user else None
        )
        process_incoming_message(ret, c_from, user)
Beispiel #3
0
def receive_public():
    """
    Receive a public Salmon Slap and process it now.
    """
    dmp = DiasporaMessageParser(DiasporaContact.get_by_username)
    ret, c_from = dmp.decode(request.form['xml'], None)
    try:
        process_incoming_message(ret, c_from, None)
        return 'OK'
    except Exception as e:
        err = format_exc()
        current_app.logger.error(err)
        db.session.expunge_all()
        queue_item = MessageQueue()
        queue_item.local_user = None
        queue_item.remote = None
        queue_item.format = MessageQueue.PUBLIC_INCOMING
        queue_item.body = request.form['xml'].encode('ascii')
        queue_item.last_attempted_at = datetime.now()
        if not isinstance(e, TryLater):
            queue_item.error = err.encode('utf-8')
        db.session.add(queue_item)
        if isinstance(e, TryLater):
            pass
        else:
            return 'Error', 400
    finally:
        db.session.commit()

    # Sneakily attempt to process one item off the backlog
    try:
        queue_items = db.session.query(MessageQueue).filter(
            MessageQueue.Queries.pending_public_items()
        ).order_by(MessageQueue.created_at)
        MessageQueue.process_queue(queue_items, None, max_items=1)
    except:
        pass

    return 'OK'
Beispiel #4
0
def receive_public():
    """
    Receive a public Salmon Slap and process it now.
    """
    dmp = DiasporaMessageParser(DiasporaContact.get_by_username)
    ret, c_from = dmp.decode(request.form['xml'], None)
    try:
        process_incoming_message(ret, c_from, None)
        return 'OK'
    except Exception:
        err = format_exc()
        current_app.logger.error(err)
        db.session.expunge_all()
        queue_item = MessageQueue()
        queue_item.local_user = None
        queue_item.remote = None
        queue_item.format = MessageQueue.PUBLIC_INCOMING
        queue_item.body = request.form['xml'].encode('ascii')
        queue_item.error = err.encode('utf-8')
        db.session.add(queue_item)
        return 'Error', 400
    finally:
        db.session.commit()
Beispiel #5
0
def receive_public():
    """
    Receive a public Salmon Slap and process it now.
    """
    dmp = DiasporaMessageParser(DiasporaContact.get_by_username)
    ret, c_from = dmp.decode(request.form['xml'], None)
    try:
        process_incoming_message(ret, c_from, None)
        return 'OK'
    except Exception:
        err = format_exc()
        current_app.logger.error(err)
        db.session.expunge_all()
        queue_item = MessageQueue()
        queue_item.local_user = None
        queue_item.remote = None
        queue_item.format = MessageQueue.PUBLIC_INCOMING
        queue_item.body = request.form['xml'].encode('ascii')
        queue_item.error = err.encode('utf-8')
        db.session.add(queue_item)
        return 'Error', 400
    finally:
        db.session.commit()