Exemplo n.º 1
0
def process():
    threading.Timer(2 * 60, process).start()
    for pendingDeactiveNode in getPendingDoc(db.deactive_nodes):
        userId = pendingDeactiveNode.get('userId')
        if userId is not None:
            user = User.by_id(client, userId, 'yes')
            nodes = Node.all(user)
            for node in nodes:
                client.nodes.delete(userId, node.id)

            # set to DONE
            markDel(userId,'DEACTIVATED-NODE')
            markDoneDoc(db.deactive_nodes, userId)

    for pendingDeactiveNode in getPendingDoc(db.lock_users):
        userId = pendingDeactiveNode.get('userId')
        if userId is not None:
            user = User.by_id(client, userId, 'yes')
            if user.permission != 'MAKE-IT-GO-AWAY':
                payload = {
                    'permission': 'MAKE-IT-GO-AWAY'
                }
                client.users.update(userId, payload)

            # set to DONE
            markDel(userId,'LOCKED-USER')
            markDoneDoc(db.lock_users, userId)
def getAddenda(userId, wyre_amount, wyre_date):
    user = User.by_id(synapseClient, userId)
    addenda = ""

    options = {'page': 1, 'per_page': 20, 'type': 'SUBACCOUNT-US'}

    nodes = Node.all(user, **options)
    if not nodes:
        return addenda
    nodeid = getattr(nodes[0], 'id')

    node = Node.by_id(user, nodeid)

    transactions = Transaction.all(node, **options)

    x = len(transactions)
    print("transactions\n")
    print(x)
    for translist in range(0, x):
        amount = getattr(transactions[translist], 'amount')
        timelines = getattr(transactions[translist], 'timelines')
        real_amount = amount.get("amount")
        if real_amount == wyre_amount:
            for d in timelines:
                if d.get("status") == "CREATED":
                    if d.get("date") == wyre_date:
                        from_info = getattr(transactions[translist], 'from')
                        addenda = from_info.get("meta").get("addenda")
    print("addenda:", addenda)
    return addenda
Exemplo n.º 3
0
def list_nodes(slack_user_id, synapse_user, params):
    """Return information on the the user's Synapse nodes."""
    nodes = Node.all(user=synapse_user)
    if nodes:
        return '\n'.join([node_summary(node) for node in nodes])
    else:
        return '*No nodes found for user.*'