This commit is contained in:
Сергей Филимонов 2024-01-22 13:51:25 +07:00
parent c103fd34a3
commit 85dda3de3c
2 changed files with 11 additions and 14 deletions

View File

@ -58,7 +58,7 @@
<td> {{ entry.uuid }}</td> <td> {{ entry.uuid }}</td>
</td> </td>
<td> {{ entry.uuid }} </td>
</tr> </tr>
{% endfor %} {% endfor %}
</body> </body>

View File

@ -65,16 +65,12 @@ def main():
except Exception as e: except Exception as e:
print(e) print(e)
insDict = { insDict = {
"client": srcJson['from'], "time": srcJson['time'], "status": 1, "important": tmpIncoming[srcJson['uuid']][2]} "client": srcJson['from'], "time": srcJson['time'], "status": 1, "important": tmpIncoming[srcJson['uuid']][2], "uuid": srcJson['uuid']}
#sendMessage(srcJson['time'], srcJson['from'])
finally: finally:
print(insDict)
coll_phone.insert_one(insDict) coll_phone.insert_one(insDict)
tmpIncoming.pop(srcJson['uuid']) tmpIncoming.pop(srcJson['uuid'])
try: try:
insUserKey = {'userkey': srcJson['userkey']} insUserKey = {'userkey': srcJson['userkey']}
print(insUserKey)
print(srcJson['to'])
coll_userkey.update_one( coll_userkey.update_one(
filter={ filter={
'operator': srcJson['to'], 'operator': srcJson['to'],
@ -88,25 +84,26 @@ def main():
print(e) print(e)
if srcJson['direction'] == 'external': if srcJson['direction'] == 'external':
# coll_phone.update_one({'$and': [{'client': srcJson['to']}, {'status': 1}]}, { print("EXTERNAL", srcJson)
# '$set': {'status': 2}})
#r = coll_phone.update_one({'$and': [{'client': {'$regex': srcJson['to']}}, {'status': 1}]}, {'$set': {'status': 2, 'callid': srcJson['uuid']}})
r = coll_phone.update_one({'$and': [{'client': {'$regex': srcJson['to']}}, {'status': {'$in': [1,4]}}]}, {'$set': {'status': 2, 'callid': srcJson['uuid']}})
if srcJson['state'] == 'HANGUP': if srcJson['state'] == 'HANGUP':
print("Full Log", srcJson)
try: try:
# Проверяем заполнено ли поле recordURL, если нет то меняем статус на 4 # Проверяем заполнено ли поле recordURL, если нет то меняем статус на 4
if len(srcJson['recordUrl']) > 4: if len(srcJson['recordUrl']) > 4:
coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'recordUrl': srcJson['recordUrl']}}) print("recordURL len > 4")
r = coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'recordUrl': srcJson['recordUrl'], 'status': 2}})
print(r)
else: else:
coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'status': 4}}) coll_prone
print("recordURL len < 4")
r = coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'status': 4}})
print(r)
except Exception as e: except Exception as e:
print(e) print(e)
print(r)
except Exception as e: except Exception as e:
print(e.with_traceback) print(e.with_traceback)
print(e) print(e)
# print(None)
exit() exit()
channel.basic_consume( channel.basic_consume(