Refactord the uuid creation code and placed it in helper_sent.insert method
refactored on the bases of comments Fixed CQ of src.helper_sent module fixed CQ for helper_sent module
This commit is contained in:
parent
881351033f
commit
e60d12ddbf
|
@ -19,6 +19,7 @@ from textwrap import fill
|
|||
from threading import Timer
|
||||
|
||||
from dialog import Dialog
|
||||
import helper_sent
|
||||
import l10n
|
||||
import network.stats
|
||||
import queues
|
||||
|
@ -32,8 +33,6 @@ from helper_ackPayload import genAckPayload
|
|||
from helper_sql import sqlExecute, sqlQuery
|
||||
from inventory import Inventory
|
||||
|
||||
import uuid
|
||||
import helper_sent
|
||||
# pylint: disable=global-statement
|
||||
|
||||
|
||||
|
@ -969,9 +968,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
|||
scrollbox(d, unicode("Because you are not currently connected to the network, "))
|
||||
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
||||
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
|
||||
msgid = uuid.uuid4().bytes
|
||||
t = (
|
||||
msgid,
|
||||
'',
|
||||
addr,
|
||||
ripe,
|
||||
sender,
|
||||
|
@ -985,7 +983,7 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
|||
0, # retryNumber
|
||||
"sent",
|
||||
2, # encodingType
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||
0
|
||||
)
|
||||
helper_sent.insert(t)
|
||||
queues.workerQueue.put(("sendmessage", addr))
|
||||
|
@ -998,9 +996,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
|||
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
||||
recv = BROADCAST_STR
|
||||
ripe = ""
|
||||
msgid = uuid.uuid4().bytes
|
||||
t = (
|
||||
msgid,
|
||||
'',
|
||||
recv,
|
||||
ripe,
|
||||
sender,
|
||||
|
@ -1014,7 +1011,7 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
|||
0, # retryNumber
|
||||
"sent", # folder
|
||||
2, # encodingType
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||
0
|
||||
)
|
||||
helper_sent.insert(t)
|
||||
queues.workerQueue.put(('sendbroadcast', ''))
|
||||
|
|
|
@ -54,7 +54,6 @@ from statusbar import BMStatusBar
|
|||
import sound
|
||||
# This is needed for tray icon
|
||||
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
|
||||
import uuid
|
||||
import helper_sent
|
||||
|
||||
try:
|
||||
|
@ -2167,9 +2166,8 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
stealthLevel = BMConfigParser().safeGetInt(
|
||||
'bitmessagesettings', 'ackstealthlevel')
|
||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||
msgid = uuid.uuid4().bytes
|
||||
t = (
|
||||
msgid,
|
||||
'',
|
||||
toAddress,
|
||||
ripe,
|
||||
fromAddress,
|
||||
|
@ -2183,7 +2181,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
0, # retryNumber
|
||||
'sent', # folder
|
||||
encoding, # encodingtype
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||
0
|
||||
)
|
||||
helper_sent.insert(t)
|
||||
toLabel = ''
|
||||
|
@ -2223,8 +2221,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
ackdata = genAckPayload(streamNumber, 0)
|
||||
toAddress = str_broadcast_subscribers
|
||||
ripe = ''
|
||||
msgid = uuid.uuid4().bytes
|
||||
t = (msgid, # msgid. We don't know what this will be until the POW is done.
|
||||
t = ('', # msgid. We don't know what this will be until the POW is done.
|
||||
toAddress,
|
||||
ripe,
|
||||
fromAddress,
|
||||
|
@ -2238,7 +2235,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
0, # retryNumber
|
||||
'sent', # folder
|
||||
encoding, # encoding type
|
||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||
0
|
||||
)
|
||||
helper_sent.insert(t)
|
||||
|
||||
|
|
|
@ -2,9 +2,20 @@
|
|||
Insert values into sent table
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_sql import sqlExecute
|
||||
|
||||
|
||||
def insert(t):
|
||||
"""Perform an insert into the `sent` table"""
|
||||
if not t[0] or not t[-1]:
|
||||
temp = list(t)
|
||||
if not t[0]:
|
||||
print('zero index is not available')
|
||||
temp[0] = uuid.uuid4().bytes # if msgid is empty the put uuid
|
||||
if not t[-1]:
|
||||
print('Lasr index is not available')
|
||||
temp[-1] = BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||
t = tuple(temp)
|
||||
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
||||
|
|
Loading…
Reference in New Issue
Block a user