ADD. New Status Recall

This commit is contained in:
2024-01-19 14:19:22 +07:00
parent c52dc734f6
commit ccd5d6874d
3 changed files with 29 additions and 12 deletions

View File

@@ -21,6 +21,11 @@ coll_userkey = db_base['userkey']
# return response
# Stats:
# 0 - ответили
# 1 - не приняли
# 2 - перезвонили успешно
def main():
connection = pika.BlockingConnection(pika.ConnectionParameters(
'rabbitmq', 5672, 'mkt', pika.PlainCredentials('rabbit', 'mrl2X0jwnYuCCiKFTshG7WKyOAhfDo')))
@@ -86,11 +91,15 @@ def main():
if srcJson['direction'] == 'external':
# coll_phone.update_one({'$and': [{'client': srcJson['to']}, {'status': 1}]}, {
# '$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': 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':
try:
coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'recordUrl': srcJson['recordUrl']}})
try:
# Проверяем заполнено ли поле recordURL, если нет то меняем статус на 4
if len(srcJson['recordUrl']) > 4:
coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'recordUrl': srcJson['recordUrl']}})
else:
coll_phone.update_one({'callid':srcJson['uuid']}, {'$set': {'status': 4}})
except Exception as e:
print(e)
print(r)