Commit 1ef9fed3 authored by Valentin Samir's avatar Valentin Samir

[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.
parent 64b0ee04
......@@ -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'))
......
......@@ -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)
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