Exemplo n.º 1
0
def _send_node_order_sent_message(node_order_id):
    node_order = get_node_order(node_order_id)
    subject = u'ThreeFold node ready to ship out'
    msg = u'Good news, your ThreeFold node (order id %s) has been prepared for shipment.' \
          u' It will be handed over to our shipping partner soon.' \
          u'\nThanks again for accepting hosting duties and helping to grow the ThreeFold Grid close to the users.' % \
          node_order_id
    send_message_and_email(node_order.app_user, msg, subject)
Exemplo n.º 2
0
def notify_new_referral(my_username, app_user):
    iyo_user = get_user(my_username)

    subject = u'%s just used your invitation code' % iyo_user.firstname
    message = u'Hi!\n' \
              u'Good news, %s %s has used your invitation code.' % (iyo_user.firstname, iyo_user.lastname)

    send_message_and_email(app_user, message, subject)
Exemplo n.º 3
0
def _send_tokens_assigned_message(app_user):
    subject = u'ThreeFold tokens assigned'
    message = 'Dear ThreeFold Member, we have just assigned your tokens to your wallet. ' \
              'It may take up to an hour for them to appear in your wallet. ' \
              '\n\nWe would like to take this opportunity to remind you to have a paper backup of your wallet. ' \
              'You can make such a backup by writing down the 29 words you can use to restore the wallet. ' \
              '\nYou can find these 29 words by going to Settings -> Security -> threefold. ' \
              '\n\nThank you once again for getting on board!'
    send_message_and_email(app_user, message, subject)
Exemplo n.º 4
0
def _send_sign_investment_reminder(agreement_id, message_type):
    agreement = get_investment_agreement(agreement_id)
    if agreement.status != InvestmentAgreement.STATUS_CREATED:
        return

    if message_type == u'long':
        message = 'Dear ThreeFold Member,\n\n' \
                  'Thank you for joining the ThreeFold Foundation! Your contract has been created and is ready to be signed and processed.\n' \
                  'You can find your created %s Purchase Agreement in your ThreeFold messages.' % (agreement.token)
    elif message_type == u'short':
        message = 'Dear ThreeFold Member,\n\n' \
                  'It appears that your created %s Purchase Agreement has not been signed yet.' % (agreement.token)
    else:
        return
    subject = u'Your Purchase Agreement is ready to be signed'

    send_message_and_email(agreement.app_user, message, subject)
Exemplo n.º 5
0
def _send_node_status_update_message(app_user, from_status, to_status, now):
    if from_status == u'running':
        subject = u'Connection to your node has been lost since %s' % now
        msg = u'Dear ThreeFold Member,\n\n' \
              u'Connection to your node has been lost since %s. Please check the network connection of your node.\n' \
              u'Kind regards,\n' \
              u'The ThreeFold Team' % (now)
    elif to_status == u'running':
        subject = u'Connection to your node has been resumed since %s' % now
        msg = u'Dear ThreeFold Member,\n\n' \
              u'Congratulations! Your node is now successfully connected to our system, and has been resumed since %s.\n' \
              u'Kind regards,\n' \
              u'The ThreeFold Team' % (now)
    else:
        logging.debug(
            "_send_node_status_update_message not sending message for status '%s' => '%s'",
            from_status, to_status)
        return

    send_message_and_email(app_user, msg, subject)
Exemplo n.º 6
0
def send_payment_instructions(app_user, agreement_id, message_prefix):
    agreement = get_investment_agreement(agreement_id)
    params = {
        'currency': agreement.currency,
        'iban': BANK_ACCOUNTS.get(agreement.currency, BANK_ACCOUNTS['USD']),
        'account_number': ACCOUNT_NUMBERS.get(agreement.currency),
        'reference': agreement.reference,
        'message_prefix': message_prefix
    }
    if agreement.currency == "BTC":
        params['amount'] = '{:.8f}'.format(agreement.amount)
        message = u"""%(message_prefix)sPlease use the following transfer details
Amount: %(currency)s %(amount)s - wallet 3GTf7gWhvWqfsurxXpEj6DU7SVoLM3wC6A

Please inform us by email at [email protected] when you have made payment.

Reference: %(reference)s"""

    else:
        params['amount'] = '{:.2f}'.format(agreement.amount)
        message = u"""%(message_prefix)sPlease use the following transfer details
Amount: %(currency)s %(amount)s

Bank: Mashreq Bank

Bank address: Al Hawai Tower, Ground Floor Sheikh Zayed Road - PO Box 36612 - UAE Dubai

Account number: %(account_number)s

IBAN: %(iban)s / BIC : BOMLAEAD

For the attention of Green IT Globe Holdings FZC, a company incorporated under the laws of Sharjah, United Arab Emirates, with registered office at SAIF Zone, SAIF Desk Q1-07-038/B

Important: The payment must be made from a bank account registered under your name. Please use %(reference)s as reference."""  # noQA

    msg = message % params
    subject = u'ThreeFold payment instructions'
    send_message_and_email(app_user, msg, subject)
Exemplo n.º 7
0
def send_payment_instructions(app_user, agreement_id, message_prefix, reminder=False):
    agreement = get_investment_agreement(agreement_id)
    if reminder and agreement.status != InvestmentAgreement.STATUS_SIGNED:
        return
    elif not reminder:
        deferred.defer(send_payment_instructions, app_user, agreement_id, message_prefix, True,
                       _countdown=14 * DAY, _queue=SCHEDULED_QUEUE)
    username = get_iyo_username(app_user)
    profile = get_tff_profile(username)
    params = {
        'currency': agreement.currency,
        'reference': agreement.reference,
        'message_prefix': message_prefix,
        'bank_account': get_bank_account_info(agreement.currency, agreement.payment_info,
                                              profile.kyc.utility_bill_verified),
    }

    if agreement.currency == 'BTC':
        params['amount'] = '{:.8f}'.format(agreement.amount)
        params['notes'] = u'Please inform us by email at [email protected] when you have made payment.'
    else:
        params['amount'] = '{:.2f}'.format(agreement.amount)
        params['notes'] = u'For the attention of ThreeFold FZC, a company incorporated under the laws of Sharjah, ' \
            u'United Arab Emirates, with registered office at SAIF Zone, SAIF Desk Q1-07-038/B'

    subject = u'ThreeFold payment instructions'
    msg = u"""%(message_prefix)sHere are your payment instructions for the purchase of your ThreeFold Tokens.

Please use the following transfer details:  
Amount: %(currency)s %(amount)s  
%(bank_account)s

%(notes)s

Please use %(reference)s as reference.""" % params
    send_message_and_email(app_user, msg, subject)
Exemplo n.º 8
0
def _order_node(order_key, user_email, app_id, steps):
    logging.info('Receiving order of Zero-Node')
    app_user = create_app_user_by_email(user_email, app_id)

    overview_step = get_step(steps, 'message_overview')
    if overview_step and overview_step.answer_id == u"button_use":
        api_key = get_rogerthat_api_key()
        user_data_keys = [
            'name', 'email', 'phone', 'billing_address', 'address',
            'shipping_name', 'shipping_email', 'shipping_phone',
            'shipping_address'
        ]
        user_data = system.get_user_data(api_key, user_email, app_id,
                                         user_data_keys)
        billing_info = ContactInfo(name=user_data['name'],
                                   email=user_data['email'],
                                   phone=user_data['phone'],
                                   address=user_data['billing_address']
                                   or user_data['address'])

        if user_data['shipping_name']:
            shipping_info = ContactInfo(name=user_data['shipping_name'],
                                        email=user_data['shipping_email'],
                                        phone=user_data['shipping_phone'],
                                        address=user_data['shipping_address'])
        else:
            shipping_info = billing_info

        updated_user_data = None
    else:
        name = get_step_value(steps, 'message_name')
        email = get_step_value(steps, 'message_email')
        phone = get_step_value(steps, 'message_phone')
        billing_address = get_step_value(steps, 'message_billing_address')
        updated_user_data = {
            'name': name,
            'email': email,
            'phone': phone,
            'billing_address': billing_address,
        }

        billing_info = ContactInfo(name=name,
                                   email=email,
                                   phone=phone,
                                   address=billing_address)

        same_shipping_info_step = get_step(steps,
                                           'message_choose_shipping_info')
        if same_shipping_info_step and same_shipping_info_step.answer_id == u"button_yes":
            shipping_info = billing_info
        else:
            shipping_name = get_step_value(steps, 'message_shipping_name')
            shipping_email = get_step_value(steps, 'message_shipping_email')
            shipping_phone = get_step_value(steps, 'message_shipping_phone')
            shipping_address = get_step_value(steps,
                                              'message_shipping_address')
            updated_user_data.update({
                'shipping_name': shipping_name,
                'shipping_email': shipping_email,
                'shipping_phone': shipping_phone,
                'shipping_address': shipping_address,
            })

            shipping_info = ContactInfo(name=shipping_name,
                                        email=shipping_email,
                                        phone=shipping_phone,
                                        address=shipping_address)
    socket_step = get_step(steps, 'message_socket')
    socket = socket_step and socket_step.answer_id.replace('button_', '')

    # Only one node is allowed per user, and one per location
    if NodeOrder.has_order_for_user_or_location(
            app_user, billing_info.address) and not DEBUG:
        logging.info('User already has a node order, sending abort message')
        msg = u'Dear ThreeFold Member, we sadly cannot grant your request to host an additional ThreeFold Node:' \
              u' We are currently only allowing one Node to be hosted per ThreeFold Member and location.' \
              u' This will allow us to build a bigger base and a more diverse Grid.'
        subject = u'Your ThreeFold Node request'
        send_message_and_email(app_user, msg, subject)
        return

    # Check if user has invested >= 120 tokens
    paid_orders = InvestmentAgreement.list_by_status_and_user(
        app_user, InvestmentAgreement.STATUS_PAID)
    total_tokens = sum([o.token_count_float for o in paid_orders])
    can_host = total_tokens >= REQUIRED_TOKEN_COUNT_TO_HOST

    def trans():
        logging.debug('Storing order in the database')
        order = NodeOrder(key=order_key,
                          app_user=app_user,
                          tos_iyo_see_id=None,
                          billing_info=billing_info,
                          shipping_info=shipping_info,
                          order_time=now(),
                          status=NodeOrderStatus.APPROVED
                          if can_host else NodeOrderStatus.WAITING_APPROVAL,
                          socket=socket)
        order.put()
        if can_host:
            logging.info(
                'User has invested more than %s tokens, immediately creating node order PDF.',
                REQUIRED_TOKEN_COUNT_TO_HOST)
            deferred.defer(_create_node_order_pdf,
                           order_key.id(),
                           _transactional=True)
        else:
            logging.info(
                'User has not invested more than %s tokens, an admin needs to approve this order manually.',
                REQUIRED_TOKEN_COUNT_TO_HOST)
            deferred.defer(_inform_support_of_new_node_order,
                           order_key.id(),
                           _transactional=True)
        deferred.defer(set_hoster_status_in_user_data,
                       order.app_user,
                       False,
                       _transactional=True)
        if updated_user_data:
            deferred.defer(put_user_data,
                           app_user,
                           updated_user_data,
                           _transactional=True)

    ndb.transaction(trans)