def send_message(self, to_jid_list, message, html_message=None, atom_message=None): if settings.IM_TEST_ONLY: to_jid_list = [x for x in to_jid_list if x.base() in settings.IM_TEST_JIDS] raw_xml = False message = encoding.smart_str(message) body = message if html_message or atom_message: raw_xml = True body_builder = ["<body>%s</body>" % (html.escape(body.strip())),] if html_message: html_message = encoding.smart_str(html_message) body_builder.append(html_message) if atom_message: atom_message = encoding.smart_str(atom_message) body_builder.append(atom_message) body = u'\n'.join([encoding.smart_unicode(x) for x in body_builder]) body = body.encode('ascii', 'xmlcharrefreplace') xmpp_service = component.best['xmpp_service'] xmpp_service.send_message([j.base() for j in to_jid_list], body, raw_xml=raw_xml)
def send_message(self, to_jid_list, message, html_message=None, atom_message=None): if settings.IM_TEST_ONLY: to_jid_list = [x for x in to_jid_list if x.base() in settings.IM_TEST_JIDS] message = encoding.smart_str(message) if html_message: html_message = encoding.smart_str(html_message) if atom_message: atom_message = encoding.smart_str(atom_message) xmpp_service = component.best['xmpp_service'] xmpp_service.send_message([j.base() for j in to_jid_list], message, html_message=html_message, atom_message=atom_message)
def send_message(self, to_jid_list, message, html_message=None, atom_message=None): if settings.IM_TEST_ONLY: to_jid_list = [ x for x in to_jid_list if x.base() in settings.IM_TEST_JIDS ] message = encoding.smart_str(message) if html_message: html_message = encoding.smart_str(html_message) if atom_message: atom_message = encoding.smart_str(atom_message) xmpp_service = component.best['xmpp_service'] xmpp_service.send_message([j.base() for j in to_jid_list], message, html_message=html_message, atom_message=atom_message)
def send_message(self, to_list, message): if not to_list: return try: to_list = self.filter_targets(to_list, message) except exception.Error: exception.log_warning() return # global monthly sms limit # TODO(termie): this means that no messages will be sent if any # will go over the limit, is this really the behavior # we want? for i in range(0, len(to_list)): throttle.throttle(None, "sms_global_send", month=settings.THROTTLE_SMS_GLOBAL_MONTH) message = encoding.smart_str(message) sms_service = component.best["sms_service"] sms_service.send_message(to_list, message)
def send_message(self, to_list, message): if not to_list: return try: to_list = self.filter_targets(to_list, message) except exception.Error: exception.log_warning() return # global monthly sms limit # TODO(termie): this means that no messages will be sent if any # will go over the limit, is this really the behavior # we want? for i in range(0, len(to_list)): throttle.throttle(None, 'sms_global_send', month=settings.THROTTLE_SMS_GLOBAL_MONTH) message = encoding.smart_str(message) sms_service = component.best['sms_service'] sms_service.send_message(to_list, message)