From: Michael Tremer Date: Mon, 15 Oct 2018 15:34:51 +0000 (+0100) Subject: people: Show calls to landline numbers X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8476e80f0346296ef023871bc3b20a42eaf0add2;p=ipfire.org.git people: Show calls to landline numbers Signed-off-by: Michael Tremer --- diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 0fd16cbc..6547ec4b 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -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: diff --git a/src/backend/talk.py b/src/backend/talk.py index 30f11213..559b83e2 100644 --- a/src/backend/talk.py +++ b/src/backend/talk.py @@ -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)