From: Michael Tremer Date: Wed, 10 Oct 2018 18:05:33 +0000 (+0100) Subject: talk: Remove lots of old unused code X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4cb2a8a058d49dfa2f9d7fdeb2e322a5cbd5c220;p=ipfire.org.git talk: Remove lots of old unused code Signed-off-by: Michael Tremer --- diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 0151fb71..7490e915 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -297,14 +297,6 @@ class Account(Object): if "sipRoutingObject" in self.classes: return self._get_first_attribute("sipRoutingAddress") - def sip_is_online(self): - assert self.sip_id - - if not hasattr(self, "_is_online"): - self._is_online = self.backend.talk.user_is_online(self.sip_id) - - return self._is_online - @lazy_property def sip_registrations(self): sip_registrations = [] diff --git a/src/backend/talk.py b/src/backend/talk.py index 63626196..5ff48e47 100644 --- a/src/backend/talk.py +++ b/src/backend/talk.py @@ -182,141 +182,6 @@ class Talk(Object): return accounts - def get_lines(self, account=None): - accounts_cache = {} - - if account and not account.is_talk_enabled(): - return [] - - if account: - res = self.db.query("SELECT contact AS location, expires, user_agent, socket \ - FROM location WHERE domain = %s AND username = %s ORDER BY expires DESC", - "ipfire.org", account.sip_id) - else: - res = self.db.query("SELECT username, domain, contact AS location, \ - expires, user_agent, socket FROM location ORDER BY username, expires DESC") - - result = [] - for row in res: - if account: - row.account = account - elif row.username: - try: - row.account = accounts_cache[row.username] - except KeyError: - row.account = accounts_cache[row.username] = \ - self.accounts.get_by_sip_id(row.username) - else: - row.account = None - - # Check if TLS is used - row.tls_enabled = row.socket.startswith("tls:") - - # Cut off everything after ; - row.location, sep, rest = row.location.partition(";") - - result.append(row) - - return result - - def _process_sip_uri(self, sip_uri): - sip_uri, delimiter, rest = sip_uri.partition(";") - - m = re.match(r"^sip:([0-9]{4})@ipfire\.org", sip_uri) - if m: - return m.group(1) - - # Remove trailing default port - if sip_uri.endswith(":5060"): - sip_uri = sip_uri.replace(":5060", "") - - return sip_uri - - def _process_cdr(self, entries, replace_sip_uris=False): - accounts_cache = {} - - result = [] - for row in entries: - if replace_sip_uris: - row["caller"] = self._process_sip_uri(row.caller) - - try: - row["caller_account"] = accounts_cache[row.caller] - except KeyError: - row["caller_account"] = accounts_cache[row.caller] = \ - self.accounts.get_by_sip_id(row.caller) - - if replace_sip_uris: - row["called"] = self._process_sip_uri(row.called) - - try: - row["called_account"] = accounts_cache[row.called] - except KeyError: - row["called_account"] = accounts_cache[row.called] = \ - self.accounts.get_by_sip_id(row.called) - - if not row.called_account: - row["called_conference"] = self.get_conference(row.called) - else: - row["called_conference"] = None - - try: - row["time"] = datetime.datetime.fromutctimestamp(row.time) - except: - pass - - result.append(row) - - return result - - def get_call_log(self, account, limit=25): - if account: - res = self.db.query("SELECT * FROM cdr WHERE (caller = %s OR called = %s) \ - ORDER BY time DESC LIMIT %s", account.sip_id, account.sip_id, limit) - else: - res = self.db.query("SELECT * FROM cdr ORDER BY time DESC LIMIT %s", limit) - - return self._process_cdr(res) - - def get_channels(self, account=None): - channels = [] - for c in a.list_channels(): - if account and not account.sip_id in (c.caller, c.callee): - continue - - channels.append(c) - - return sorted(channels) - - def get_channel(self, channel_id, account=None): - channels = self.get_channels(account=account) - - for channel in channels: - if channel.id == channel_id: - return channel - - def get_ongoing_calls(self, account=None, sip_id=None): - if account and sip_id is None: - sip_id = account.sip_id - - # If the given account does not have a SIP ID, - # we not need to search for any active sessions - if sip_id is None: - return [] - - if sip_id: - sip_id = "sip:%s@%%" % sip_id - - res = self.db.query("SELECT from_uri AS caller, \ - to_uri AS called, start_time AS time FROM dialog \ - WHERE from_uri LIKE %s OR to_uri LIKE %s ORDER BY time", - sip_id, sip_id) - else: - res = self.db.query("SELECT from_uri AS caller, to_uri AS called, \ - start_time AS time FROM dialog ORDER BY time") - - return self._process_cdr(res, replace_sip_uris=True) - # Conferences @property diff --git a/src/templates/talk/conferences.html b/src/templates/talk/conferences.html deleted file mode 100644 index 1f8a35ec..00000000 --- a/src/templates/talk/conferences.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Conferences") }}{% end block %} - -{% block body %} - - - {% for conf in conferences %} -
-
- - {{ conf.sip_id }} - - - -
- -

- {{ _("IPFire Conference Room %s") % conf.no }} -

- - {% if conf.participants %} -
- -
    - {% for p in conf.participants %} -
  • - {% if p.caller_account %} - {{ p.caller_account.name }} - {{ p.caller_account.name }} - {% else %} - {{ p.caller }} - {% end %} - {{ _("joined %s") % locale.format_date(p.time, relative=True) }} -
  • - {% end %} -
- {% end %} -
- {% end %} -{% end block %} diff --git a/src/templates/talk/confirm-hangup.html b/src/templates/talk/confirm-hangup.html deleted file mode 100644 index a6dfdadf..00000000 --- a/src/templates/talk/confirm-hangup.html +++ /dev/null @@ -1,39 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Hangup Channel") }}{% end block %} - -{% block body %} -
- {% raw xsrf_form_html() %} - -
-
-
-

{{ _("Hangup Channel") }}

- -

- {{ _("You are about to hangup this channel") }} -

- -
- -

- {% module TalkContact(channel.caller, name=channel.caller_name) %} -

- -

- -

- -

- {% module TalkContact(channel.callee, application=channel.application) %} -

- -
- - -
-
-
-
-{% end block %} diff --git a/src/templates/talk/diagnosis.html b/src/templates/talk/diagnosis.html deleted file mode 100644 index dc7ea86e..00000000 --- a/src/templates/talk/diagnosis.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Diagnosis") }}{% end block %} - -{% block body %} - - - {% module TalkOngoingCalls() %} - - {% module TalkLines(show_account=True) %} -{% end block %} diff --git a/src/templates/talk/phonebook-contact.html b/src/templates/talk/phonebook-contact.html deleted file mode 100644 index 1b7b2ee5..00000000 --- a/src/templates/talk/phonebook-contact.html +++ /dev/null @@ -1,122 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ account.name }}{% end block %} - -{% block body %} -
-
-

{{ account.name }}

- -
-
- {{ account.name }} -
-
- {% if account.sip_id %} -

{{ _("Voice over IP") }}

- -
    -
  • -

    - {% if account.uses_sip_forwarding() %} - - {{ account.sip_id }} - {% elif account.sip_is_online() %} - - - {{ account.sip_id }} - {% else %} - - - {{ account.sip_id }} - {% end %} - {{ account.sip_id }} -

    -
  • - -
  • - - {{ account.sip_url }} - -
  • - - {% if account.sip_password and (current_user == account or current_user.is_admin()) %} -
  • - - {{ _("Password") }}: {{ account.sip_password }} - -
  • - {% end %} -
- {% end %} - - {% if account.sip_id and account.email %} -
- {% end %} - - {% if account.email %} - - {% end %} -
- -
-

{{ _("Postal Address") }}

-
- {{ account.name }}
- - {% for line in account.address.splitlines() %} - {{ line }}
- {% end %} -
-
- - {% if account.telephone_numbers %} -

{{ _("Telephone") }}

- -
    - {% for number in account.telephone_numbers %} -
  • - {% if number in account.mobile_telephone_numbers %} - - {% elif number in account.home_telephone_numbers %} - - {% else %} - - {% end %} - {{ number }} -
  • - {% end %} -
- {% end %} -
- -
-
-
- {% if current_user.is_admin() and account.uses_sip_forwarding() %} - - {% end %} - - {% if current_user == account or current_user.is_admin() %} - {% module TalkLines(account) %} - {% module TalkOngoingCalls(account) %} - {% module TalkCallLog(account) %} - {% end %} -
-
-
-
-{% end block %} diff --git a/src/templates/talk/phonebook.html b/src/templates/talk/phonebook.html deleted file mode 100644 index ef099d95..00000000 --- a/src/templates/talk/phonebook.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Phonebook") }}{% end block %} - -{% block body %} - -
-
-

{{ _("Phonebook") }}

- -
-
- - - - - - - - - - - {% for e in phonebook %} - - - - - - - {% end %} - -
NameeMailPhoneAvatar
{{ e.name }} - {{ e.email }} - {% if e.sip_id %} - - {% if e.uses_sip_forwarding() %} - {{ e.sip_id }} - {% elif e.sip_is_online() %} - {{ e.sip_id }} - {% else %} - {{ e.sip_id }} - {% end %} - {% end %} - {{ e.name }}
-
-
-
-
-{% end block %}