replaced insert into sent query with helper_sent.insert method and also replaced empty msgid with uuid

This commit is contained in:
navjot 2020-09-15 00:05:55 +05:30
parent 601158f6fb
commit 881351033f
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
2 changed files with 25 additions and 17 deletions

View File

@ -31,6 +31,9 @@ from bmconfigparser import BMConfigParser
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
from inventory import Inventory from inventory import Inventory
import uuid
import helper_sent
# pylint: disable=global-statement # pylint: disable=global-statement
@ -966,9 +969,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
scrollbox(d, unicode("Because you are not currently connected to the network, ")) scrollbox(d, unicode("Because you are not currently connected to the network, "))
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel') stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel) ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
sqlExecute( msgid = uuid.uuid4().bytes
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", t = (
"", msgid,
addr, addr,
ripe, ripe,
sender, sender,
@ -982,7 +985,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
0, # retryNumber 0, # retryNumber
"sent", "sent",
2, # encodingType 2, # encodingType
BMConfigParser().getint('bitmessagesettings', 'ttl')) BMConfigParser().getint('bitmessagesettings', 'ttl')
)
helper_sent.insert(t)
queues.workerQueue.put(("sendmessage", addr)) queues.workerQueue.put(("sendmessage", addr))
else: # Broadcast else: # Broadcast
if recv == "": if recv == "":
@ -993,9 +998,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
ackdata = genAckPayload(decodeAddress(addr)[2], 0) ackdata = genAckPayload(decodeAddress(addr)[2], 0)
recv = BROADCAST_STR recv = BROADCAST_STR
ripe = "" ripe = ""
sqlExecute( msgid = uuid.uuid4().bytes
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", t = (
"", msgid,
recv, recv,
ripe, ripe,
sender, sender,
@ -1009,7 +1014,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
0, # retryNumber 0, # retryNumber
"sent", # folder "sent", # folder
2, # encodingType 2, # encodingType
BMConfigParser().getint('bitmessagesettings', 'ttl')) BMConfigParser().getint('bitmessagesettings', 'ttl')
)
helper_sent.insert(t)
queues.workerQueue.put(('sendbroadcast', '')) queues.workerQueue.put(('sendbroadcast', ''))

View File

@ -54,6 +54,8 @@ from statusbar import BMStatusBar
import sound import sound
# This is needed for tray icon # This is needed for tray icon
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
import uuid
import helper_sent
try: try:
from plugins.plugin import get_plugin, get_plugins from plugins.plugin import get_plugin, get_plugins
@ -2165,10 +2167,9 @@ class MyForm(settingsmixin.SMainWindow):
stealthLevel = BMConfigParser().safeGetInt( stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel') 'bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () msgid = uuid.uuid4().bytes
sqlExecute( t = (
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', msgid,
'',
toAddress, toAddress,
ripe, ripe,
fromAddress, fromAddress,
@ -2184,7 +2185,7 @@ class MyForm(settingsmixin.SMainWindow):
encoding, # encodingtype encoding, # encodingtype
BMConfigParser().getint('bitmessagesettings', 'ttl') BMConfigParser().getint('bitmessagesettings', 'ttl')
) )
helper_sent.insert(t)
toLabel = '' toLabel = ''
queryreturn = sqlQuery('''select label from addressbook where address=?''', queryreturn = sqlQuery('''select label from addressbook where address=?''',
toAddress) toAddress)
@ -2222,7 +2223,8 @@ class MyForm(settingsmixin.SMainWindow):
ackdata = genAckPayload(streamNumber, 0) ackdata = genAckPayload(streamNumber, 0)
toAddress = str_broadcast_subscribers toAddress = str_broadcast_subscribers
ripe = '' ripe = ''
t = ('', # msgid. We don't know what this will be until the POW is done. msgid = uuid.uuid4().bytes
t = (msgid, # msgid. We don't know what this will be until the POW is done.
toAddress, toAddress,
ripe, ripe,
fromAddress, fromAddress,
@ -2238,8 +2240,7 @@ class MyForm(settingsmixin.SMainWindow):
encoding, # encoding type encoding, # encoding type
BMConfigParser().getint('bitmessagesettings', 'ttl') BMConfigParser().getint('bitmessagesettings', 'ttl')
) )
sqlExecute( helper_sent.insert(t)
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
toLabel = str_broadcast_subscribers toLabel = str_broadcast_subscribers