|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
import logging
|
|
|
|
|
import mitel_ommclient2
|
|
|
|
|
import time
|
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger("fieldpoc.dect")
|
|
|
|
|
|
|
|
|
@ -45,7 +46,7 @@ class Dect:
|
|
|
|
|
return "{}{:0>4}".format(self.temp_num_prefix, current_temp_extension)
|
|
|
|
|
|
|
|
|
|
def get_sip_password_for_number(self, num):
|
|
|
|
|
return num
|
|
|
|
|
return hashlib.sha256(bytes.fromhex((self.fp.config.dect.sipsecret + str(num))[-16:])).hexdigest()[:16]
|
|
|
|
|
|
|
|
|
|
def create_and_bind_user(self, d, num):
|
|
|
|
|
u = self.c.create_user(num)
|
|
|
|
@ -79,10 +80,12 @@ class Dect:
|
|
|
|
|
e = extensions_by_num.get(user.num)
|
|
|
|
|
if not e:
|
|
|
|
|
# user in omm, but not as dect in nerd
|
|
|
|
|
# TODO: delete in omm
|
|
|
|
|
if user.num.startswith(next(self.fp.extensions.extensions_by_type("temp")).num):
|
|
|
|
|
users_by_ext[user.num] = user
|
|
|
|
|
users_by_uid[user.uid] = user
|
|
|
|
|
else:
|
|
|
|
|
pass
|
|
|
|
|
# TODO: delete in omm
|
|
|
|
|
continue
|
|
|
|
|
elif e._c['name'] != user.name:
|
|
|
|
|
self.c.set_user_name(user.uid, e._c['name'])
|
|
|
|
@ -135,4 +138,19 @@ class Dect:
|
|
|
|
|
if created_tmp_ext:
|
|
|
|
|
self.fp.queues['routing'].put({"type": "sync"})
|
|
|
|
|
|
|
|
|
|
elif msg.get("type") == "claim":
|
|
|
|
|
e = None
|
|
|
|
|
for ext in self.fp.extensions.extensions_by_type("dect"):
|
|
|
|
|
if ext._c.get('dect_claim_token') and ext._c['dect_claim_token'] == msg.get("token")[4:]:
|
|
|
|
|
e = ext
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if e:
|
|
|
|
|
user = next(self.c.find_users(lambda u: u.num == msg.get("extension")))
|
|
|
|
|
if self.fp.temp_extensions.get(user.num):
|
|
|
|
|
self.fp.temp_extensions.pop(user.num)
|
|
|
|
|
self.c.set_user_num(user.uid, e.num)
|
|
|
|
|
self.c.set_user_sipauth(user.uid, e.num, self.get_sip_password_for_number(e.num))
|
|
|
|
|
self.c.set_user_name(user.uid, e._c['name'])
|
|
|
|
|
|
|
|
|
|
self.c.connection.close()
|
|
|
|
|