[sip/sms] Possibilité d'envoyer des IM vers la fédération sip
Ça marche probablement, je ne peux pas tester, je n'ai pas de compte sip supportant les IM hors crans.
This commit is contained in:
parent
64b0ee0478
commit
1ef9fed378
2 changed files with 13 additions and 4 deletions
|
@ -136,7 +136,10 @@ class Sms(object):
|
||||||
else:
|
else:
|
||||||
caller = "ServiceCenter"
|
caller = "ServiceCenter"
|
||||||
|
|
||||||
to = "sip:1%04d" % dst['aid'][0].value
|
if isinstance(dst, lc_ldap.objets.proprio):
|
||||||
|
to = "sip:1%04d" % dst['aid'][0].value
|
||||||
|
else:
|
||||||
|
to = dst
|
||||||
|
|
||||||
ast_manager = Manager('sms', secrets.get('asterisk_sms_passwd'))
|
ast_manager = Manager('sms', secrets.get('asterisk_sms_passwd'))
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,14 @@ if __name__ == '__main__':
|
||||||
dst = args.dst
|
dst = args.dst
|
||||||
if not dst:
|
if not dst:
|
||||||
dst = src
|
dst = src
|
||||||
else:
|
elif not dst.startswith('sip:') and '@' in dst and not dst.endswith('@crans.org'):
|
||||||
dst = ldap.search(u"(|(uid=%(dst)s)(mailAlias=%(dst)s@crans.org)(canonicalAlias=%(dst)s@crans.org)(aid=%(dst)s)(aid=%(dst_alt)s))" % {'dst' : dst, 'dst_alt' : dst.replace('sip:','')[1:]})[0]
|
dst = 'sip:%s' % dst
|
||||||
|
elif not dst.startswith('sip:'):
|
||||||
|
dst = dst.replace('@crans.org', '')
|
||||||
|
try:
|
||||||
|
dst = ldap.search(u"(|(uid=%(dst)s)(mailAlias=%(dst)s@crans.org)(canonicalAlias=%(dst)s@crans.org)(aid=%(dst)s))" % {'dst' : dst})[0]
|
||||||
|
except IndexError:
|
||||||
|
sys.stderr.write("Pas utilisateur trouvé pour %s\n" % args.dst)
|
||||||
|
sys.exit(1)
|
||||||
sms=Sms("dbname='django' user='crans' host='pgsql.adm.crans.org'", "voip_sms")
|
sms=Sms("dbname='django' user='crans' host='pgsql.adm.crans.org'", "voip_sms")
|
||||||
sms.send(dst, sys.stdin.read(), src)
|
sms.send(dst, sys.stdin.read(), src)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue