From 1ef9fed3787986e1ea6e64ffae6c7f322d7e905e Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Wed, 13 Nov 2013 13:54:20 +0100 Subject: [PATCH] =?UTF-8?q?[sip/sms]=20Possibilit=C3=A9=20d'envoyer=20des?= =?UTF-8?q?=20IM=20vers=20la=20f=C3=A9d=C3=A9ration=20sip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ça marche probablement, je ne peux pas tester, je n'ai pas de compte sip supportant les IM hors crans. --- sip/asterisk.py | 5 ++++- sip/send_sms.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sip/asterisk.py b/sip/asterisk.py index 1a94c789..787fef3c 100644 --- a/sip/asterisk.py +++ b/sip/asterisk.py @@ -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')) diff --git a/sip/send_sms.py b/sip/send_sms.py index c07a5f94..6e8ee4c2 100755 --- a/sip/send_sms.py +++ b/sip/send_sms.py @@ -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)