fix: replace retained task drafts with current input
This commit is contained in:
1 parent
e22af6a0ec
commit
bd54b5f06a
7 files changed
+121
-16
No files matched your search
@@ -32,7 +32,7 @@ import urllib.parse as url
|
||||
import urllib.request as http
|
||||
import webbrowser
|
||||
|
||||
VERSION = '0.4.0'
|
||||
VERSION = '0.4.1'
|
||||
|
||||
class Failure(Exception):
|
||||
def __init__(self, message, status=0, payload=None):
|
||||
@@ -578,8 +578,9 @@ def tasks(client, profile, words):
|
||||
def capture(payload):
|
||||
pending=profile.data.setdefault('task_outbox',{})
|
||||
if len(pending)>=20 and payload['request_id'] not in pending:raise Failure('20 pending captures retained. Retry them before adding more.')
|
||||
if payload['request_id'] in pending and pending[payload['request_id']] != payload:raise Failure('A different draft with this request ID is retained. Use pages task retry '+payload['request_id'])
|
||||
replaced=payload['request_id'] in pending and pending[payload['request_id']] != payload
|
||||
pending[payload['request_id']]=payload;profile.save()
|
||||
if replaced:print('Replaced the retained draft with the current input.',file=sys.stderr)
|
||||
try: result=client.json(TASK_API+'capture',method='POST',data=payload)
|
||||
except Failure as e:
|
||||
print('Draft retained; retry with: pages task retry '+payload['request_id'],file=sys.stderr)
|
||||
@@ -622,7 +623,7 @@ def tasks(client, profile, words):
|
||||
value=getattr(a,attr)
|
||||
if value is not None:payload[key]=task_project(client,value) if attr=='project' else value
|
||||
# A retry of the same pending mail must not drift across a month boundary
|
||||
# when Date was missing. Other changed options still fail closed.
|
||||
# when Date was missing. Changed input replaces the pending draft below.
|
||||
old=profile.data.get('task_outbox',{}).get(payload['request_id'])
|
||||
if action=='from-mail' and old and {k:v for k,v in old.items() if k!='wiki_suffix'}=={k:v for k,v in payload.items() if k!='wiki_suffix'}:
|
||||
payload=old.copy()
|
||||
|
||||
Reference in new issue
Block a user