本文整理汇总了Python中corehq.apps.sms.models.CallLog.inbound_entry_exists方法的典型用法代码示例。如果您正苦于以下问题:Python CallLog.inbound_entry_exists方法的具体用法?Python CallLog.inbound_entry_exists怎么用?Python CallLog.inbound_entry_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.CallLog
的用法示例。
在下文中一共展示了CallLog.inbound_entry_exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fire_sms_callback_event
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import inbound_entry_exists [as 别名]
def fire_sms_callback_event(reminder, handler, recipients, verified_numbers):
current_event = reminder.current_event
for recipient in recipients:
send_message = False
if reminder.callback_try_count > 0:
if reminder.event_initiation_timestamp:
event = ExpectedCallbackEventLog.view("sms/expected_callback_event",
key=[reminder.domain,
json_format_datetime(reminder.event_initiation_timestamp),
recipient.get_id],
include_docs=True,
limit=1).one()
if not event:
continue
if event.status == CALLBACK_RECEIVED:
continue
if CallLog.inbound_entry_exists(recipient.doc_type,
recipient.get_id, reminder.event_initiation_timestamp):
event.status = CALLBACK_RECEIVED
event.save()
continue
else:
continue
if (reminder.callback_try_count >=
len(current_event.callback_timeout_intervals)):
# On the last callback timeout, instead of sending the SMS
# again, log the missed callback
if event:
event.status = CALLBACK_MISSED
event.save()
else:
send_message = True
else:
# It's the first time sending the sms, so create an expected
# callback event
send_message = True
event = ExpectedCallbackEventLog(
domain=reminder.domain,
date=reminder.event_initiation_timestamp,
couch_recipient_doc_type=recipient.doc_type,
couch_recipient=recipient.get_id,
status=CALLBACK_PENDING,
)
event.save()
if send_message:
fire_sms_event(reminder, handler, [recipient], verified_numbers,
workflow=WORKFLOW_CALLBACK)
return True
示例2: fire_sms_callback_event
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import inbound_entry_exists [as 别名]
def fire_sms_callback_event(reminder, handler, recipients, verified_numbers):
current_event = reminder.current_event
if handler.recipient in [RECIPIENT_CASE, RECIPIENT_USER]:
# If there are no recipients, just move to the next reminder event
if len(recipients) == 0:
return True
# If the callback has been received, skip sending the next timeout message
if reminder.callback_try_count > 0:
# Lookup the expected callback event
if reminder.event_initiation_timestamp is None:
event = None
else:
event = ExpectedCallbackEventLog.view("sms/expected_callback_event",
key=[reminder.domain, json_format_datetime(reminder.event_initiation_timestamp), recipients[0].get_id],
include_docs=True,
limit=1).one()
# NOTE: If last_fired is None, it means that the reminder fired for the first time on a timeout interval
if reminder.last_fired is not None and CallLog.inbound_entry_exists(recipients[0].doc_type, recipients[0].get_id, reminder.last_fired):
reminder.skip_remaining_timeouts = True
if event is not None:
event.status = CALLBACK_RECEIVED
event.save()
return True
elif reminder.callback_try_count >= len(current_event.callback_timeout_intervals):
# On the last callback timeout, instead of sending the SMS again, log the missed callback
if event is not None:
event.status = CALLBACK_MISSED
event.save()
return True
else:
# It's the first time sending the sms, so create an expected callback event
event = ExpectedCallbackEventLog(
domain = reminder.domain,
date = reminder.event_initiation_timestamp,
couch_recipient_doc_type = recipients[0].doc_type,
couch_recipient = recipients[0].get_id,
status = CALLBACK_PENDING,
)
event.save()
return fire_sms_event(reminder, handler, recipients, verified_numbers, workflow=WORKFLOW_CALLBACK)
else:
# TODO: Implement sms callback for RECIPIENT_OWNER and RECIPIENT_SURVEY_SAMPLE
return False