def process_message(msg, new_message=False, new_contact=False): """ Processes the passed in message dealing with new contacts or mage messages appropriately. """ print("M[%09d] Processing - %s" % (msg.id, msg.text)) start = time.time() # if message was created in Mage... if new_message: handle_new_message(msg.org, msg) if new_contact: handle_new_contact(msg.org, msg.contact) Msg.process_message(msg) print("M[%09d] %08.3f s - %s" % (msg.id, time.time() - start, msg.text))
def fire_follow_triggers(channel_id, contact_urn_id, new_mage_contact=False): """ Fires a follow trigger """ urn = ContactURN.objects.select_related('contact').get(pk=contact_urn_id) contact = urn.contact # for now, flows start against contacts rather than URNs channel = Channel.objects.get(id=channel_id) # if contact was just created in Mage then.. # * its dynamic groups won't have been initialized # * we need to update our cached contact counts if new_mage_contact: handle_new_contact(contact.org, contact) Trigger.catch_triggers(contact, Trigger.TYPE_FOLLOW, channel)
def fire_follow_triggers(channel_id, contact_urn_id, new_mage_contact=False): """ Fires a follow trigger """ urn = ContactURN.objects.select_related('contact').get(pk=contact_urn_id) contact = urn.contact # for now, flows start against contacts rather than URNs channel = Channel.objects.get(id=channel_id) # if contact was just created in Mage then.. # * its dynamic groups won't have been initialized # * we need to update our cached contact counts if new_mage_contact: handle_new_contact(contact.org, contact) if channel.is_active and channel.org: event = ChannelEvent.create(channel, urn.identity, ChannelEvent.TYPE_FOLLOW, timezone.now()) event.handle()