]> git.ipfire.org Git - ipfire.org.git/commitdiff
people: Show calls to landline numbers
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 Oct 2018 15:34:51 +0000 (16:34 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 Oct 2018 16:05:38 +0000 (17:05 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py
src/backend/talk.py

index 0fd16cbc7c803fe2351564ff3d0bbf68a65bbd93..6547ec4b5d84468c10b1fb429d0a0289cb9d391f 100644 (file)
@@ -323,15 +323,19 @@ class Account(Object):
 
        @property
        def _telephone_numbers(self):
-               return self.attributes.get("telephoneNumber") or []
+               return list((x.decode() for x in self.attributes.get("telephoneNumber") or []))
 
        @property
        def home_telephone_numbers(self):
-               return self.attributes.get("homePhone") or []
+               return list((x.decode() for x in self.attributes.get("homePhone") or []))
 
        @property
        def mobile_telephone_numbers(self):
-               return self.attributes.get("mobile") or []
+               return list((x.decode() for x in self.attributes.get("mobile") or []))
+
+       @property
+       def _all_telephone_numbers(self):
+               return [ self.sip_id, ] + self.telephone_numbers
 
        def avatar_url(self, size=None):
                if self.backend.debug:
index 30f112133523b3c99ea4c0a1a67c08858b4a9beb..559b83e2f6f21875e19808c879a7a24456c435c6 100644 (file)
@@ -37,8 +37,10 @@ class Freeswitch(Object):
        def get_sip_channels(self, account):
                res = self.db.query("SELECT * FROM channels \
                        WHERE (direction = %s AND cid_num = %s) OR \
-                               (direction = %s AND callee_num = %s) ORDER BY created_epoch",
-                       "inbound", account.sip_id, "outbound", account.sip_id)
+                               (direction = %s AND (callee_num = %s OR callee_num = ANY(%s))) \
+                               ORDER BY created_epoch",
+                       "inbound", account.sip_id, "outbound", account.sip_id,
+                       account._all_telephone_numbers)
 
                channels = []
 
@@ -50,11 +52,11 @@ class Freeswitch(Object):
 
        def get_cdr_by_account(self, account, date=None, limit=None):
                res = self.db.query("SELECT * FROM cdr \
-                       WHERE ((caller_id_number = %s AND bleg_uuid IS NOT NULL) \
-                               OR (destination_number = %s AND bleg_uuid IS NULL)) \
+                       WHERE ((caller_id_number = ANY(%s) AND bleg_uuid IS NOT NULL) \
+                               OR (destination_number = ANY(%s) AND bleg_uuid IS NULL)) \
                                AND (%s IS NULL OR start_stamp::date = %s) \
-                       ORDER BY end_stamp DESC LIMIT %s", account.sip_id,
-                       account.sip_id, date, date, limit)
+                       ORDER BY end_stamp DESC LIMIT %s", account._all_telephone_numbers,
+                       account._all_telephone_numbers, date, date, limit)
 
                for row in res:
                        yield CDR(self, data=row)