feat(work): recover text and attachment delivery independently

This commit is contained in:
ex_tianzy
2026-11-23 14:49:51 +08:00
parent 1b3fded4ae
commit 3f4b8f983b
7 changed files with 210 additions and 24 deletions
+18
View File
@@ -68,6 +68,24 @@ async def test_result_is_encrypted_durable_and_delivered_once_after_worker_loss(
assert env['store'].db.execute('SELECT ciphertext FROM work_result_outbox_v2').fetchone()['ciphertext']==''
async def test_expired_delivery_receipt_is_readable_without_admitting_mutations(env):
task(env)
assert (await upload(env)).status_code==200
await env['app'].state.deliveries.flush()
db=env['store'].db
with db:db.execute("UPDATE work_tasks_v2 SET deadline=? WHERE turn_id=?", (time.time()-1,'task-durable'))
execution_path='/work/v2/tasks/state'
assert (await env['client'].post(execution_path,json=wire(env,execution_path,task_id='task-durable'))).status_code==403
path='/work/v2/tasks/delivery'
result=await env['client'].post(path,json=wire(env,path,task_id='task-durable'))
assert result.status_code==200 and result.json()['delivery']['text']['platform_sent']
assert (await upload(env)).status_code==403
other=await env['client'].post(path,json=wire(env,path,host='b'*32,task_id='task-durable'))
assert other.status_code==403
with db:db.execute("UPDATE work_tasks_v2 SET deadline=? WHERE turn_id=?", (time.time()-8*86400,'task-durable'))
assert (await env['client'].post(path,json=wire(env,path,task_id='task-durable'))).status_code==403
async def test_result_conflict_and_foreign_task_are_rejected(env):
task(env)
assert (await upload(env)).status_code==200