Added status updates to functions.
pull/2/head
Hailey Clark 6 years ago
parent 7edfe05263
commit 66526f1e03
  1. 2
      app-ajax.py
  2. 9
      appdb.py
  3. 3
      callback-sms.py

@ -86,7 +86,7 @@ def submitMessage():
returndata = json.dumps({'error': 'Unable to send SMS'}) returndata = json.dumps({'error': 'Unable to send SMS'})
else: else:
msgTS = time.strftime("%Y-%m-%dT%H:%m:%SZ") msgTS = time.strftime("%Y-%m-%dT%H:%m:%SZ")
appdb.logsms_db(msg_id, msgTS, 'outbound', targetDid, fromDid, 0.0040, message) appdb.logsms_db(msg_id, msgTS, 'outbound', targetDid, fromDid, 0.0040, 'pending', message)
returndata = json.dumps({"msg" : message, "fromdid" : fromDid, 'targetdid' : targetDid,}) returndata = json.dumps({"msg" : message, "fromdid" : fromDid, 'targetdid' : targetDid,})
return returndata return returndata

@ -15,15 +15,12 @@ sqlpass = config.get("sql","sqlpass")
sqldb = config.get("sql","sqldb") sqldb = config.get("sql","sqldb")
def logsms_db(msg_id, msg_ts, direction, to_did, from_did, cost, msg): def logsms_db(msg_id, msg_ts, direction, to_did, from_did, cost, status, msg):
#This statement logs a SMS to the smslog table. #This statement logs a SMS to the smslog table.
db = pymysql.connect(host=sqlhost, user=sqluser, passwd=sqlpass, db=sqldb) db = pymysql.connect(host=sqlhost, user=sqluser, passwd=sqlpass, db=sqldb)
cur = db.cursor() cur = db.cursor()
if direction == 'inbound':
status = 'success' cur.execute("INSERT INTO messages (`timestamp`, `provider_timestamp`,`direction`, `source_number`, `dest_number`, `cost`,`pid`,`status`, `body`)VALUES \
else:
status = 'pending'
cur.execute("INSERT INTO messages (`timestamp`, `provider_timestamp`,`direction`, `source_number`, `dest_number`, `cost`,`pid`,`status, `body`)VALUES \
(%s, %s, %s, %s, %s, %s, %s, %s, %s)",(int(time.time()),msg_ts, direction, from_did, to_did, cost, msg_id, status, msg)) (%s, %s, %s, %s, %s, %s, %s, %s, %s)",(int(time.time()),msg_ts, direction, from_did, to_did, cost, msg_id, status, msg))
db.commit() db.commit()
db.close() db.close()

@ -40,8 +40,9 @@ def smsinbound():
body = json_content['data']['attributes']['body'] body = json_content['data']['attributes']['body']
msg_timestamp = json_content['data']['attributes']['timestamp'] msg_timestamp = json_content['data']['attributes']['timestamp']
smsRate = json_content['data']['attributes']['amount_display'].replace('$','') smsRate = json_content['data']['attributes']['amount_display'].replace('$','')
status = 'success'
appdb.logsms_db(msg_id, msg_timestamp, 'inbound', reply_from, reply_to, smsRate, body) # Lets log to our silly db. appdb.logsms_db(msg_id, msg_timestamp, 'inbound', reply_from, reply_to, smsRate, status, body) # Lets log to our silly db.
#This command seems to make this function happen twice. #This command seems to make this function happen twice.
# appsms.sendsms(reply_to, reply_from, "Message received. Please wait for a reply.") # appsms.sendsms(reply_to, reply_from, "Message received. Please wait for a reply.")
return "0" return "0"

Loading…
Cancel
Save