def send(self, message, contact=None): if not contact: contact = self.contact if contact.is_test: Contact.set_simulation(True) incoming = self.create_msg(direction=INCOMING, contact=contact, text=message) # evaluate the inbound message against our triggers first from temba.triggers.models import Trigger if not Trigger.find_and_handle(incoming): Flow.find_and_handle(incoming) return Msg.objects.filter(response_to=incoming).order_by('pk').first()
def handle_message(msg): """ Only used for testing to approximate how mailroom handles a message """ from temba.flows.models import Flow from temba.msgs.models import Msg from temba.triggers.models import Trigger if msg.contact.is_blocked: msg.visibility = Msg.VISIBILITY_ARCHIVED msg.save(update_fields=["visibility", "modified_on"]) else: handled = Trigger.find_and_handle(msg) if not handled: handled, msgs = Flow.find_and_handle(msg) if not handled: Trigger.catch_triggers(msg, Trigger.TYPE_CATCH_ALL, msg.channel) mark_handled(msg)