Use msgid as query key

This commit is contained in:
Teruteru 2023-03-13 14:14:38 +09:00
parent 3d19c3f23f
commit bf07ae2f7a
No known key found for this signature in database
GPG Key ID: CBEB9600540FCA36

View File

@ -723,13 +723,13 @@ class singleWorker(StoppableThread):
''' WHERE status IN ('doingpubkeypow', 'doingmsgpow') ''' ''' WHERE status IN ('doingpubkeypow', 'doingmsgpow') '''
''' AND folder='sent' ''') ''' AND folder='sent' ''')
queryreturn = sqlQuery( queryreturn = sqlQuery(
'''SELECT toaddress, fromaddress, subject, message, ''' '''SELECT msgid, toaddress, fromaddress, subject, message, '''
''' ackdata, status, ttl, retrynumber, encodingtype FROM ''' ''' ackdata, status, ttl, retrynumber, encodingtype FROM '''
''' sent WHERE (status='msgqueued' or status='forcepow') ''' ''' sent WHERE (status='msgqueued' or status='forcepow') '''
''' and folder='sent' ''') ''' and folder='sent' ''')
# while we have a msg that needs some work # while we have a msg that needs some work
for row in queryreturn: for row in queryreturn:
toaddress, fromaddress, subject, message, \ msgid, toaddress, fromaddress, subject, message, \
ackdata, status, TTL, retryNumber, encoding = row ackdata, status, TTL, retryNumber, encoding = row
# toStatus # toStatus
_, toAddressVersionNumber, toStreamNumber, toRipe = \ _, toAddressVersionNumber, toStreamNumber, toRipe = \
@ -759,8 +759,8 @@ class singleWorker(StoppableThread):
elif config.has_section(toaddress): elif config.has_section(toaddress):
if not sqlExecute( if not sqlExecute(
'''UPDATE sent SET status='doingmsgpow' ''' '''UPDATE sent SET status='doingmsgpow' '''
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''', ''' WHERE msgid=? ''',
toaddress msgid
): ):
continue continue
status = 'doingmsgpow' status = 'doingmsgpow'
@ -775,8 +775,8 @@ class singleWorker(StoppableThread):
# set the status of this msg to doingmsgpow # set the status of this msg to doingmsgpow
if not sqlExecute( if not sqlExecute(
'''UPDATE sent SET status='doingmsgpow' ''' '''UPDATE sent SET status='doingmsgpow' '''
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''', ''' WHERE msgid=? ''',
toaddress msgid
): ):
continue continue
status = 'doingmsgpow' status = 'doingmsgpow'
@ -804,10 +804,9 @@ class singleWorker(StoppableThread):
# We already sent a request for the pubkey # We already sent a request for the pubkey
sqlExecute( sqlExecute(
'''UPDATE sent SET status='awaitingpubkey', ''' '''UPDATE sent SET status='awaitingpubkey', '''
''' sleeptill=? WHERE toaddress=? ''' ''' sleeptill=? WHERE msgid=? ''',
''' AND status='msgqueued' ''',
int(time.time()) + 2.5 * 24 * 60 * 60, int(time.time()) + 2.5 * 24 * 60 * 60,
toaddress msgid
) )
queues.UISignalQueue.put(( queues.UISignalQueue.put((
'updateSentItemStatusByToAddress', ( 'updateSentItemStatusByToAddress', (
@ -858,12 +857,8 @@ class singleWorker(StoppableThread):
'''UPDATE sent SET ''' '''UPDATE sent SET '''
''' status='doingmsgpow', ''' ''' status='doingmsgpow', '''
''' retrynumber=0 WHERE ''' ''' retrynumber=0 WHERE '''
''' toaddress=? AND ''' ''' msgid=? ''',
''' (status='msgqueued' or ''' msgid)
''' status='awaitingpubkey' or '''
''' status='doingpubkeypow') AND '''
''' folder='sent' ''',
toaddress)
del state.neededPubkeys[tag] del state.neededPubkeys[tag]
break break
# else: # else:
@ -879,8 +874,8 @@ class singleWorker(StoppableThread):
sqlExecute( sqlExecute(
'''UPDATE sent SET ''' '''UPDATE sent SET '''
''' status='doingpubkeypow' WHERE ''' ''' status='doingpubkeypow' WHERE '''
''' toaddress=? AND status='msgqueued' AND folder='sent' ''', ''' msgid=? ''',
toaddress msgid
) )
queues.UISignalQueue.put(( queues.UISignalQueue.put((
'updateSentItemStatusByToAddress', ( 'updateSentItemStatusByToAddress', (