本文整理汇总了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