From 881351033f29b004ff4bb3f7fc9fbb5dbf522300 Mon Sep 17 00:00:00 2001 From: navjot Date: Tue, 15 Sep 2020 00:05:55 +0530 Subject: [PATCH] replaced insert into sent query with helper_sent.insert method and also replaced empty msgid with uuid --- src/bitmessagecurses/__init__.py | 23 +++++++++++++++-------- src/bitmessageqt/__init__.py | 19 ++++++++++--------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/bitmessagecurses/__init__.py b/src/bitmessagecurses/__init__.py index 17dba22b..cc9eac41 100644 --- a/src/bitmessagecurses/__init__.py +++ b/src/bitmessagecurses/__init__.py @@ -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', '')) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 6c561932..fa69bbd9 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -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, @@ -2183,8 +2184,8 @@ class MyForm(settingsmixin.SMainWindow): 'sent', # folder 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