[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:
Valentin Samir 2013-11-13 13:54:20 +01:00
parent 64b0ee0478
commit 1ef9fed378
2 changed files with 13 additions and 4 deletions

View file

@ -136,7 +136,10 @@ class Sms(object):
else:
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'))

View file

@ -40,8 +40,14 @@ if __name__ == '__main__':
dst = args.dst
if not dst:
dst = src
else:
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]
elif not dst.startswith('sip:') and '@' in dst and not dst.endswith('@crans.org'):
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.send(dst, sys.stdin.read(), src)