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_sql import sqlExecute, sqlQuery
from inventory import Inventory
import uuid
import helper_sent
# 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, "))
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
sqlExecute(
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
"",
msgid = uuid.uuid4().bytes
t = (
msgid,
addr,
ripe,
sender,
@ -982,7 +985,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
0, # retryNumber
"sent",
2, # encodingType
BMConfigParser().getint('bitmessagesettings', 'ttl'))
BMConfigParser().getint('bitmessagesettings', 'ttl')
)
helper_sent.insert(t)
queues.workerQueue.put(("sendmessage", addr))
else: # Broadcast
if recv == "":
@ -993,9 +998,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
recv = BROADCAST_STR
ripe = ""
sqlExecute(
"INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
"",
msgid = uuid.uuid4().bytes
t = (
msgid,
recv,
ripe,
sender,
@ -1009,7 +1014,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
0, # retryNumber
"sent", # folder
2, # encodingType
BMConfigParser().getint('bitmessagesettings', 'ttl'))
BMConfigParser().getint('bitmessagesettings', 'ttl')
)
helper_sent.insert(t)
queues.workerQueue.put(('sendbroadcast', ''))

View File

@ -54,6 +54,8 @@ 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:
from plugins.plugin import get_plugin, get_plugins
@ -2165,10 +2167,9 @@ class MyForm(settingsmixin.SMainWindow):
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(streamNumber, stealthLevel)
t = ()
sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'',
msgid = uuid.uuid4().bytes
t = (
msgid,
toAddress,
ripe,
fromAddress,
@ -2184,7 +2185,7 @@ class MyForm(settingsmixin.SMainWindow):
encoding, # encodingtype
BMConfigParser().getint('bitmessagesettings', 'ttl')
)
helper_sent.insert(t)
toLabel = ''
queryreturn = sqlQuery('''select label from addressbook where address=?''',
toAddress)
@ -2222,7 +2223,8 @@ class MyForm(settingsmixin.SMainWindow):
ackdata = genAckPayload(streamNumber, 0)
toAddress = str_broadcast_subscribers
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,
ripe,
fromAddress,
@ -2238,8 +2240,7 @@ class MyForm(settingsmixin.SMainWindow):
encoding, # encoding type
BMConfigParser().getint('bitmessagesettings', 'ttl')
)
sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
helper_sent.insert(t)
toLabel = str_broadcast_subscribers