@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:
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 = []
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)