Ejemplo n.º 1
0
def returnInbox():
    if not app_auth.is_logged_in():
        return json.dumps(
            {'error': 'Unable to send SMS, you are not logged in'})

    # userid = flask.session['account_id']
    loginId = flask.session['loginid']
    results = appdb.getSMSbyAccount(loginId, 20)
    jsonresult = ''
    i = 0
    for x in results:
        if i >= 1:
            jsonresult = jsonresult + ',' + json.dumps({
                "body": x[9],
                "fromdid": x[6],
                "targetdid": x[7],
                'timestamp': x[4],
                'status': x[10],
                'direction': x[5]
            })
        else:
            jsonresult = json.dumps({
                "body": x[9],
                "fromdid": x[6],
                "targetdid": x[7],
                "timestamp": x[4],
                'status': x[10],
                'direction': x[5]
            })
        i += 1
    jsonresult = '[' + jsonresult + ']'
    return jsonresult
Ejemplo n.º 2
0
def PrivacyPolicy():
    if app_debug == '1':
        pprint.pprint(flask.session)
    if app_auth.is_logged_in():
        loggedin = True
    else:
        loggedin = False
    return flask.render_template('pp.html', loggedin=loggedin)
Ejemplo n.º 3
0
def markread(msg_id):
    '''This will mark the id for the message as read.'''
    if not app_auth.is_logged_in():
        return json.dumps(
            {'error': 'Unable to send SMS, you are not logged in'})
    if appdb.updateReadStatus(msg_id, 1) == 0:
        return json.dumps({'error': 'Unable to update the read status.'})
    else:
        return json.dumps({'status': 'success'})
Ejemplo n.º 4
0
def launchPage():
    if app_debug == '1':
        pprint.pprint(flask.session)
    if app_auth.is_logged_in():
        loggedin = True
    else:
        loggedin = False

    if app_debug == '1':
        pprint.pprint(loggedin)
        pprint.pprint("loggedin")

    return flask.render_template('launch.html', loggedin=loggedin)
Ejemplo n.º 5
0
def markallunread():
    '''This will mark every EVERY I said, message for the user id which should
    be pulled from session info.'''
    if not app_auth.is_logged_in():
        return json.dumps(
            {'error': 'Unable to send SMS, you are not logged in'})
    userid = flask.session['account_id']
    if appdb.updateMarkAllUnread(userid) == 0:
        return json.dumps(
            {'error': 'Nothing to update or error updating the read status.'})
    else:
        return json.dumps({'status': 'success'})
    return False
Ejemplo n.º 6
0
def landingPage():
    '''This renders the landing page'''
    # user_info = google_auth.get_user_info()
    if flask.session['loginid']:
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])
    # Going to replace google_auth with a local authentication.
    if app_auth.is_logged_in():
        loggedin = True
    else:
        loggedin = False
    return flask.render_template('landing.html',
                                 user_info=user_info,
                                 loggedin=loggedin)
Ejemplo n.º 7
0
def submitMessage():
    '''This is to submit a message.'''

    if not app_auth.is_logged_in():
        return json.dumps({'error': 'Unable to send SMS'})

    message = flask.request.form['message']
    fromDid = flask.request.form['fromdid']
    targetDid = flask.request.form['targetdid']

    # user_info = appdb.getUserInfo(
    #                              flask.session['email'],
    #                              flask.session['loginid'])
    userid = flask.session['account_id']
    result = appdb.authIdforDID(userid, fromDid)

    if userid != result:
        return json.dumps({
            'error':
            'Unauthorized UserID of ' + str(userid) + " and DID id of " +
            str(result) + " and fromDID " + str(fromDid)
        })

    if appdb.validateFrom(fromDid) is False:
        return json.dumps({'error': 'Unauthorized source phone number.'})

    uglyphone = appsms.uglyPhone(targetDid)

    # pprint.pprint('Got ' + message + ',' + fromDid)
    msg_id = appsms.sendsms(uglyphone, fromDid, message)
    if msg_id is False:  # This sends the sms!
        returndata = json.dumps({'error': 'Unable to send SMS'})
    else:
        msgTS = time.strftime("%Y-%m-%dT%H:%m:%S+00:00")
        appdb.logsms_db(msg_id, msgTS, 'outbound', uglyphone, fromDid, 0.0040,
                        'pending', message, result)
        returndata = json.dumps({
            "msg": message,
            "fromdid": fromDid,
            "targetdid": targetDid
        })
    return returndata
Ejemplo n.º 8
0
def getNumMessages(number):
    '''Return the messages from a single DID in json form'''
    # This gets the mssages based on the provided from or two DID
    if not app_auth.is_logged_in():
        return json.dumps({'error': 'You are not logged in.'})

    # We need to take and compare the authIDforDID, gotta add use id
    # to getNumSMSLog and pull the id from result.
    userid = flask.session['account_id']
    result = appdb.authIdforDID(userid, number)
    smslog = appdb.getNumSMSLog(number, 10)

    i = 0
    msgjson = ""
    for line in smslog:
        prettyto = appsms.prettyPhone(line[7])
        prettyfrom = appsms.prettyPhone(line[6])
        if i >= 1:
            msgjson = msgjson + ',' + json.dumps({
                'to': prettyto,
                'from': prettyfrom,
                'body': line[9],
                'timestamp': line[4],
                'status': line[10],
                'direction': line[5]
            })
        else:
            msgjson = json.dumps({
                'to': prettyto,
                'from': prettyfrom,
                'body': line[9],
                'timestamp': line[4],
                'status': line[10],
                'direction': line[5]
            })
        i += 1
    msgArrayJson = '[' + msgjson + ']'
    return msgArrayJson
Ejemplo n.º 9
0
def manageSingleSMS(number):
    '''This renders a view for a single SMS number and its
    associated messages'''
    if not app_auth.is_logged_in():
        return flask.render_template('deny.html',
                                     denymsg=loginMsg,
                                     loggedin=False)
    if flask.session['loginid']:
        user_info = appdb.getUserInfo(flask.session['email'],
                                      flask.session['loginid'])

    result = appdb.authIdforDID(user_info[0], number)
    prettynum = appsms.prettyPhone(number)

    if appdb.validateFrom(int(number)) and result:
        return flask.render_template('single.html',
                                     srcnumber=number,
                                     prettynum=prettynum,
                                     loggedin=True)
    else:
        return flask.render_template('notvalid.html',
                                     srcnumber=number,
                                     prettynum=prettynum,
                                     loggedin=True)
Ejemplo n.º 10
0
def about():
    if app_auth.is_logged_in():
        loggedin = True
    else:
        loggedin = False
    return flask.render_template('about.html', loggedin=loggedin)
Ejemplo n.º 11
0
def inbox():
    if app_auth.is_logged_in():
        loggedin = True
    else:
        loggedin = False
    return flask.render_template('inbox.html', loggedin=loggedin)