Example #1
0
 def generate(self):
     if not self.worker_initiated:
         return
     for medium in self.notification_mediums:
         if medium == Notification.Medium.SMS.value and settings.SEND_SMS_NOTIFICATION:
             sendSMS(self.generate_sms_phone_numbers(),
                     self.generate_sms_message(),
                     many=True)
         elif medium == Notification.Medium.SYSTEM.value:
             message = self.generate_system_message()
             for user in self.generate_system_users():
                 notification_obj = self.generate_message_for_user(
                     user, message, Notification.Medium.SYSTEM.value)
                 if not self.defer_notifications:
                     self.send_webpush_user(
                         user,
                         json.dumps({
                             "external_id":
                             str(notification_obj.external_id),
                             "title":
                             message
                         }))
         elif medium == Notification.Medium.WHATSAPP.value and settings.ENABLE_WHATSAPP:
             for user in self.generate_whatsapp_users():
                 number = user.alt_phone_number
                 notification_obj = self.generate_message_for_user(
                     user, message, Notification.Medium.WHATSAPP.value)
                 message = self.generate_whatsapp_message()
                 sendWhatsappMessage(number, message,
                                     notification_obj.external_id)
Example #2
0
def send_sms(otp, phone_number):

    if settings.USE_SMS:
        sendSMS(
            phone_number,
            "CoronaSafe Network Patient Management System Login, OTP is {} . Please do not share this Confidential Login Token with anyone else"
            .format(otp),
        )
    else:
        print(otp, phone_number)
Example #3
0
def generate_sms_for_user(phone_numbers, message):
    sendSMS(phone_numbers, message, many=True)