Commit 9b0f83fd authored by Valentin Samir's avatar Valentin Samir

[sip/asterisk/sms_daemon] Erreur via levée d'exceptions

parent efa97540
......@@ -111,14 +111,14 @@ class Sms(object):
num = params['Peer'].split('/')[1]
conn = psycopg2.connect(self.sql_params)
cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
cur.execute('SELECT * FROM %s WHERE "user"=%%s' % self.database, (num,))
cur.execute('SELECT * FROM %s WHERE "user"=%%s ORDER BY "date" ASC' % self.database, (num,))
for sms in cur.fetchall():
status, params = manager.messageSend(sms['from'], sms['to'], sms['body'], body_type='base64')
if status == 'Success':
try:
manager.messageSend(sms['from'], sms['to'], sms['body'], body_type='base64')
syslog.syslog("Message from %s successfully delivered to %s" % (sms['from'], sms['to']))
cur.execute('DELETE FROM %s WHERE id=%%s' % self.database, (sms['id'],))
conn.commit()
elif status == 'Error':
except AsteriskError as error:
syslog.syslog("Message from %s to %s : %s" % (sms['from'], sms['to'], params['Message']))
cur.close()
conn.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment