Exemplo n.º 1
0
 def __init__(self):
     try:
         self.pn = FirebasePushNotifications()
     except UndefinedEnvironmentVariable as e:
         KSR.error(e.message)
     except:
         KSR.info(traceback.format_exc())
Exemplo n.º 2
0
 def __init__(self):
     KSR.info('===== kamailio.__init__\n')
     # Re-import modules on reload
     for filename in ROUTES: # app_python3
         if filename in sys.modules:# app_python3
             KSR.info("Reload route:" + filename)# app_python3
             del sys.modules[filename] # app_python3
             exec("import " + filename) # app_python3
Exemplo n.º 3
0
 def send_push_notification(self, msg):
     KSR.info(">>> Send push notification")
     try:
         self.pn.send_push_notification(KSR.pv.get("$tU"),
                                        call_id=KSR.pv.get("$ci"),
                                        sip_from=KSR.pv.get("$fU"),
                                        loc_key=KSR.pv.get("$mi"),
                                        loc_args=KSR.pv.get("$oU"))
     except:
         KSR.info(traceback.format_exc())
     return 1
Exemplo n.º 4
0
 def extract_contact(self, msg):
     KSR.info(">>> Extract contact")
     try:
         result = self.parse_contact(KSR.pv.get("$ct"))
         if result is None:
             return 1
         contact = ";".join([result["prefix"], result["suffix"]])
         self.update_contact_header(contact)
         self.pn.update_pn_contact(
             result["username"],
             app_id=result["app_id"],
             pn_type=result["pn_type"],
             pn_token=result["pn_token"],
         )
     except:
         KSR.info(traceback.format_exc())
     return 1
Exemplo n.º 5
0
 def child_init(self, rank):
     KSR.info('===== kamailio.child_init(%d)\n' % rank);
     return 0;
Exemplo n.º 6
0
 def ksr_reply_route(self, msg):
     KSR.info("===== response - from kamailio python script\n");
     return 1;
Exemplo n.º 7
0
 def __init__(self):
     KSR.info('===== kamailio.__init__\n');
Exemplo n.º 8
0
def mod_init():
    KSR.info("===== from Python mod init\n");
    # dumpObj(KSR);
    return kamailio();
Exemplo n.º 9
0
 def child_init(self, rank):
     KSR.info('===== kamailio.child_init(%d)\n' % rank);
     return 0;
Exemplo n.º 10
0
 def ksr_reply_route(self, msg):
     KSR.info("===== response - from kamailio python script\n");
     return 1;
Exemplo n.º 11
0
 def __init__(self):
     KSR.info('===== kamailio.__init__\n');
Exemplo n.º 12
0
def mod_init():
    KSR.info("===== from Python mod init\n");
    # dumpObj(KSR);
    return kamailio();
def dumpObj(obj):
    for attr in dir(obj):
        KSR.info("obj.%s = %s\n" % (attr, getattr(obj, attr)))
Exemplo n.º 14
0
def mod_init():
    KSR.info("===== from Python mod init\n")
    return kamailio()
Exemplo n.º 15
0
 def send_push_notification(self,
                            username,
                            call_id=None,
                            sip_from=None,
                            loc_key=None,
                            loc_args=None):
     tokens = []
     for token in self.redis_client.smembers(username):
         [app_id, pn_type, pn_token] = token.decode("utf-8").split(";")
         KSR.info(f">>> username = {username}")
         KSR.info(f">>> app_id = {app_id}")
         KSR.info(f">>> pn_type = {pn_type}")
         KSR.info(f">>> pn_token = {pn_token}")
         data_message = self.create_data_message(call_id=call_id,
                                                 sip_from=sip_from,
                                                 loc_key=loc_key,
                                                 loc_args=loc_args)
         KSR.info(json.dumps(data_message, indent=4, sort_keys=True))
         result = self.push_service.notify_single_device(
             registration_id=pn_token,
             message_title="Incoming call",
             message_body=f"Incoming call from {sip_from}",
             data_message=data_message,
             time_to_live=120,
         )
         KSR.info(json.dumps(result, indent=4, sort_keys=True))
Exemplo n.º 16
0
 def child_init(self, rank):
     KSR.info('===== kamailio.child_init({})\n'.format(rank))
     return 0