From: Michael Tremer Date: Wed, 15 Mar 2017 18:25:57 +0000 (+0000) Subject: talk: Show more status about ongoing calls X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56851b014d2128028a98dae763b90f12b3e90a8e;p=ipfire.org.git talk: Show more status about ongoing calls Signed-off-by: Michael Tremer --- diff --git a/templates/talk/modules/contact.html b/templates/talk/modules/contact.html index 84b1b6e6..a8bd7080 100644 --- a/templates/talk/modules/contact.html +++ b/templates/talk/modules/contact.html @@ -1,4 +1,15 @@ -{% if account %} +{% if application == "ConfBridge" %} + {{ _("Conference Room %s") % number }} + +{% elif application == "VoiceMail" %} + {{ _("Voicemail") }}: + + {% if account %} + {{ account.name }} + ({{ number }}) + {% end %} + +{% elif account %} {{ account.name }} ({{ number }}) @@ -6,9 +17,6 @@ {% elif number == "900" %} {{ _("Conference Service") }} -{% elif number in ("901", "902", "903", "904", "905", "906", "907", "908", "909") %} - {{ _("Conference Room #%s") % number[2] }} - {% elif number in ("980", "981", "982", "983", "984", "985", "986", "987", "988", "989") %} {{ _("Parked Calls Extension") }} ({{ number }}) diff --git a/templates/talk/modules/ongoing-calls.html b/templates/talk/modules/ongoing-calls.html index d57f6331..8473dcf8 100644 --- a/templates/talk/modules/ongoing-calls.html +++ b/templates/talk/modules/ongoing-calls.html @@ -23,7 +23,7 @@ - {% module TalkContact(c.callee) %} + {% module TalkContact(c.callee, application=c.application) %} diff --git a/webapp/backend/asterisk.py b/webapp/backend/asterisk.py index d404bbab..8f382579 100644 --- a/webapp/backend/asterisk.py +++ b/webapp/backend/asterisk.py @@ -191,6 +191,20 @@ class Channel(object): return int(seconds) + _states = { + "4" : "ringing", + "6" : "connected", + } + + @property + def state(self): + state = self.status.get("ChannelState") + + try: + return self._states[state] + except KeyError: + return + @property def format(self): return "%s/%s" % ( @@ -223,10 +237,29 @@ class Channel(object): @property def callee(self): - num = self.status.get("DNID") + if self.application == "ConfBridge": + return self.data # Will have the conference room number + + elif self.application == "VoiceMail": + try: + user, rest = self.data.split("@", 1) + except: + return self.data + + return user + + num = self.status.get("EffectiveConnectedLineNum") or self.status.get("DNID") return self._format_number(num) + @property + def application(self): + return self.status.get("Application") + + @property + def data(self): + return self.status.get("Data") + class Peer(object): def __init__(self, manager, peer_id): diff --git a/webapp/ui_modules.py b/webapp/ui_modules.py index f72f65ab..1cedb458 100644 --- a/webapp/ui_modules.py +++ b/webapp/ui_modules.py @@ -329,11 +329,11 @@ class ProgressBarModule(UIModule): class TalkContactModule(UIModule): - def render(self, number, name=None): + def render(self, number, name=None, application=None): account = self.accounts.get_by_sip_id(number) return self.render_string("talk/modules/contact.html", - account=account, number=number, name=name) + account=account, number=number, name=name, application=application) class TalkCallLogModule(UIModule):