Commit cd6b6aeb authored by Etienne Allovon's avatar Etienne Allovon

Merge branch '2506-fix-mds-phone-hint-status' into 'master'

2506 fix mds phone hint status

See merge request !53
parents 2d9ded6f 1c8c67ba
xivo-dao (2019.05.02) xivo-callisto; urgency=medium
* 2506 Generate hint only on mds where the user belongs
-- Laurent Meiller <lmeiller@avencall.com> Mon, 13 May 2019 10:39:41 +0200
xivo-dao (2019.05.00) xivo-callisto; urgency=medium
[ Tomas Taraba ]
......
......@@ -61,6 +61,8 @@ def _common_filter(query, context):
UserFeatures.id == UserLine.user_id)
.join(user_extension,
UserLine.extension_id == user_extension.id)
.join(LineFeatures,
LineFeatures.id == UserLine.line_id)
.filter(user_extension.context == context)
.filter(UserLine.main_user == True)
.filter(UserLine.main_line == True)
......@@ -87,7 +89,8 @@ def user_hints(session, context):
(LineFeatures.protocol == 'sip', literal_column("'SIP/'") + UserSIP.name),
(LineFeatures.protocol == 'sccp', literal_column("'SCCP/'") + SCCPLine.name),
(LineFeatures.protocol == 'custom', UserCustom.interface)
]).label('argument'))
]).label('argument'),
LineFeatures.configregistrar.label('mediaserver'))
.join(UserLine.userfeatures)
.join(UserLine.linefeatures)
.outerjoin(UserSIP,
......@@ -113,7 +116,8 @@ def user_hints(session, context):
return tuple(Hint(user_id=row.user_id,
extension=row.extension,
argument=row.argument)
argument=row.argument,
mediaserver=row.mediaserver)
for row in query)
......@@ -131,14 +135,16 @@ def conference_hints(session, context):
return tuple(Hint(user_id=None,
extension=row.extension,
argument=None)
argument=None,
mediaserver='default')
for row in query)
@daosession
def service_hints(session, context):
query = (session.query(Extension.exten.label('extension'),
UserFeatures.id.label('user_id'))
UserFeatures.id.label('user_id'),
LineFeatures.configregistrar.label('mediaserver'))
.join(FuncKeyDestService,
FuncKeyDestService.extension_id == Extension.id)
.join(FuncKeyMapping,
......@@ -148,7 +154,8 @@ def service_hints(session, context):
return tuple(Hint(user_id=row.user_id,
extension=row.extension,
argument=None)
argument=None,
mediaserver=row.mediaserver)
for row in query)
......@@ -156,7 +163,8 @@ def service_hints(session, context):
def forward_hints(session, context):
query = (session.query(Extension.exten.label('extension'),
UserFeatures.id.label('user_id'),
FuncKeyDestForward.number.label('argument'))
FuncKeyDestForward.number.label('argument'),
LineFeatures.configregistrar.label('mediaserver'))
.join(FuncKeyDestForward,
FuncKeyDestForward.extension_id == Extension.id)
.join(FuncKeyMapping,
......@@ -166,7 +174,8 @@ def forward_hints(session, context):
return tuple(Hint(user_id=row.user_id,
extension=clean_extension(row.extension),
argument=row.argument)
argument=row.argument,
mediaserver=row.mediaserver)
for row in query)
......@@ -174,7 +183,8 @@ def forward_hints(session, context):
def agent_hints(session, context):
query = (session.query(sql.cast(FuncKeyDestAgent.agent_id, Unicode).label('argument'),
UserFeatures.id.label('user_id'),
Extension.exten.label('extension'))
Extension.exten.label('extension'),
LineFeatures.configregistrar.label('mediaserver'))
.join(Extension,
Extension.id == FuncKeyDestAgent.extension_id)
.join(FuncKeyMapping,
......@@ -184,20 +194,23 @@ def agent_hints(session, context):
return tuple(Hint(user_id=row.user_id,
extension=clean_extension(row.extension),
argument=row.argument)
argument=row.argument,
mediaserver=row.mediaserver)
for row in query)
@daosession
def custom_hints(session, context):
query = (session.query(FuncKeyDestCustom.exten.label('extension'))
query = (session.query(FuncKeyDestCustom.exten.label('extension'),
LineFeatures.configregistrar.label('mediaserver'))
.join(FuncKeyMapping,
FuncKeyDestCustom.func_key_id == FuncKeyMapping.func_key_id))
query = _common_filter(query, context)
return tuple(Hint(user_id=None,
extension=row.extension,
argument=None)
argument=None,
mediaserver=row.mediaserver)
for row in query)
......@@ -205,7 +218,8 @@ def custom_hints(session, context):
def bsfilter_hints(session, context):
bsfilter_extension = clean_extension(_find_extenfeatures(session, 'bsfilter'))
query = (session.query(sql.cast(FuncKeyDestBSFilter.filtermember_id, Unicode).label('argument'))
query = (session.query(sql.cast(FuncKeyDestBSFilter.filtermember_id, Unicode).label('argument'),
LineFeatures.configregistrar.label('mediaserver'))
.join(Callfiltermember,
Callfiltermember.id == FuncKeyDestBSFilter.filtermember_id)
.join(Callfilter,
......@@ -216,6 +230,8 @@ def bsfilter_hints(session, context):
UserLine.user_id == UserFeatures.id)
.join(Extension,
Extension.id == UserLine.extension_id)
.join(LineFeatures,
LineFeatures.id == UserLine.line_id)
.filter(UserLine.main_user == True)
.filter(UserLine.main_line == True)
.filter(Extension.commented == 0)
......@@ -224,5 +240,6 @@ def bsfilter_hints(session, context):
return tuple(Hint(user_id=None,
extension=bsfilter_extension,
argument=row.argument)
argument=row.argument,
mediaserver=row.mediaserver)
for row in query)
......@@ -225,5 +225,5 @@ class ForwardTypeConverter(object):
return self.fwd_types[model_type]
Hint = namedtuple('Hint', ['user_id', 'extension', 'argument'])
Hint = namedtuple('Hint', ['user_id', 'extension', 'argument', 'mediaserver'])
Forward = namedtuple('Forward', ['user_id', 'type', 'number'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment