]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/backend/talk.py
people: Add page with call information
[ipfire.org.git] / src / backend / talk.py
index 559b83e2f6f21875e19808c879a7a24456c435c6..a739231241384e29f3969739c3b41d78b99319b3 100644 (file)
@@ -61,6 +61,13 @@ class Freeswitch(Object):
                for row in res:
                        yield CDR(self, data=row)
 
+       def get_call_by_uuid(self, uuid):
+               res = self.db.get("SELECT * FROM cdr \
+                       WHERE uuid = %s", uuid)
+
+               if res:
+                       return CDR(self, data=res)
+
 
 class SIPRegistration(object):
        def __init__(self, freeswitch, data):
@@ -194,6 +201,25 @@ class CDR(object):
        def backend(self):
                return self.freeswitch.backend
 
+       @property
+       def db(self):
+               return self.freeswitch.db
+
+       @property
+       def uuid(self):
+               return self.data.uuid
+
+       @lazy_property
+       def bleg(self):
+               if self.data.bleg_uuid:
+                       return self.freeswitch.get_call_by_uuid(self.data.bleg_uuid)
+
+               # If we are the bleg, we need to search for one where UUID is the bleg
+               res = self.db.get("SELECT * FROM cdr WHERE bleg_uuid = %s", self.uuid)
+
+               if res:
+                       return CDR(self.freeswitch, data=res)
+
        @property
        def direction(self):
                if self.data.bleg_uuid:
@@ -235,7 +261,8 @@ class CDR(object):
 
        @property
        def user_agent(self):
-               return self.data.user_agent.replace("_", " ")
+               if self.data.user_agent:
+                       return self.data.user_agent.replace("_", " ")
 
        @property
        def size(self):