本文整理匯總了Python中corehq.apps.sms.models.SMS.inbound_entry_exists方法的典型用法代碼示例。如果您正苦於以下問題:Python SMS.inbound_entry_exists方法的具體用法?Python SMS.inbound_entry_exists怎麽用?Python SMS.inbound_entry_exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類corehq.apps.sms.models.SMS
的用法示例。
在下文中一共展示了SMS.inbound_entry_exists方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_domain_specific_delays
# 需要導入模塊: from corehq.apps.sms.models import SMS [as 別名]
# 或者: from corehq.apps.sms.models.SMS import inbound_entry_exists [as 別名]
def handle_domain_specific_delays(msg, domain_object, utcnow):
"""
Checks whether or not we need to hold off on sending an outbound message
due to any restrictions set on the domain, and delays processing of the
message if necessary.
Returns True if a delay was made, False if not.
"""
domain_now = ServerTime(utcnow).user_time(domain_object.get_default_timezone()).done()
if len(domain_object.restricted_sms_times) > 0:
if not time_within_windows(domain_now, domain_object.restricted_sms_times):
delay_processing(msg, settings.SMS_QUEUE_DOMAIN_RESTRICTED_RETRY_INTERVAL)
return True
if msg.chat_user_id is None and len(domain_object.sms_conversation_times) > 0:
if time_within_windows(domain_now, domain_object.sms_conversation_times):
sms_conversation_length = domain_object.sms_conversation_length
conversation_start_timestamp = utcnow - timedelta(minutes=sms_conversation_length)
if SMS.inbound_entry_exists(
msg.couch_recipient_doc_type,
msg.couch_recipient,
conversation_start_timestamp,
to_timestamp=utcnow
):
delay_processing(msg, 1)
return True
return False