Ver Fonte

запись цепочки трансфера в конце

svetlana há 3 anos atrás
pai
commit
b67aada200
1 ficheiros alterados com 6 adições e 1 exclusões
  1. 6 1
      app/app.py

+ 6 - 1
app/app.py

@@ -221,13 +221,14 @@ async def celCallback(mngr: Manager, msg: Message):
     if ('transferee_channel_uniqueid' in extra) and ('channel2_uniqueid' in extra):
       first = extra['transferee_channel_uniqueid'];
       second = extra['channel2_uniqueid']
+      app.cache['cel_calls'][lid]['transfers'].append((first,second)) #no cdr in db here
       app.logger.warning('first {} {}'.format(first,second))
-      await db.execute(query='update cdr set transfer_from=(select distinct linkedid from cdr where uniqueid=:first) where linkedid=:second;',values={'first': first,'second': second})
       
   if ((msg.EventName == 'CHAN_START') and (lid == msg.UniqueID)):    #save first msg
     app.cache['cel_calls'][lid] = msg
     app.cache['cel_calls'][lid]['current_channels'] = {}
     app.cache['cel_calls'][lid]['all_channels'] = {}
+    app.cache['cel_calls'][lid]['transfers'] = []
     
   if (lid in app.cache['cel_calls']):
     firstMessage = app.cache['cel_calls'][lid]
@@ -317,6 +318,10 @@ async def celCallback(mngr: Manager, msg: Message):
               'agents': [q.user for q in app.cache['queues'][msg.Exten]]}
           reply = await doCallback('queueLeave', _cb)
     if (msg.EventName == 'LINKEDID_END'):
+      for t in firstMessage['transfers']:
+        app.logger.warning('first {}'.format(t))
+        await db.execute(query='update cdr set transfer_from=(select distinct linkedid from cdr where uniqueid=:first) where linkedid=:second;',values={'first': t[1),'second': t(2)})
+
       app.cache['cel_calls'].pop(lid, False)
       app.cache['cel_queue_calls'].pop(lid, False)
     if (msg.EventName == 'USER_DEFINED') and (msg.UserDefType == 'SETVARIABLE'):