Schedule consultation bridges on demand and preserve delivery evidence
This commit is contained in:
@@ -21,6 +21,27 @@ def browser_body(text):
|
||||
return text[match.end():] if match else text
|
||||
|
||||
|
||||
def delivery_fields(row):
|
||||
"""Expose evidence-based transport stages without private queue receipts."""
|
||||
if row.get('source') != 'human' or row.get('origin') != 'coordination':
|
||||
return {}
|
||||
status = row.get('status')
|
||||
submission = row.get('submission') or {}
|
||||
if isinstance(submission, str):
|
||||
submission = json.loads(submission)
|
||||
if status in ('uncertain', 'failed'):
|
||||
return dict(delivery_stage='blocked', delivery_reason=(
|
||||
'执行结果待核对,请勿重复发送' if status == 'uncertain' else '处理失败,请查看记录'))
|
||||
if status == 'completed' and row.get('response_id'):
|
||||
return dict(delivery_stage='replied')
|
||||
if submission.get('state') == 'observed':
|
||||
return dict(delivery_stage='processing')
|
||||
if submission.get('state') == 'accepted':
|
||||
return dict(delivery_stage='delivered')
|
||||
# A local start or submitting record is not proof of host acceptance.
|
||||
return dict(delivery_stage='queued')
|
||||
|
||||
|
||||
def project(rows, links):
|
||||
by_id = {row['id']: row for row in rows}
|
||||
metadata = {link['message_id']: link for link in links}
|
||||
@@ -101,5 +122,6 @@ def project(rows, links):
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
result.append({**{k: row.get(k) for k in ('id', 'source', 'status', 'created')}, 'text': text, 'log_id':incident_links.get(group)})
|
||||
result.append({**{k: row.get(k) for k in ('id', 'source', 'status', 'created', 'reply_to')},
|
||||
**delivery_fields(row), 'text': text, 'log_id':incident_links.get(group)})
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user