From 8850a68347aac3b24087739574a4ec4a0616db86 Mon Sep 17 00:00:00 2001 From: navjot Date: Tue, 15 Sep 2020 22:13:22 +0530 Subject: [PATCH] removed the inset sent query and using the comman helper_sent.inset method for data insertion --- src/bitmessagekivy/mpybit.py | 52 +++++++++++++++++++++++++----------- src/helper_sent.py | 5 ++++ 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 6c0fa813..78921918 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -62,6 +62,7 @@ from uikivysignaler import UIkivySignaler import identiconGeneration from addresses import addBMIfNotPresent, decodeAddress +import helper_sent def toast(text): @@ -606,15 +607,24 @@ class DropDownWidget(BoxLayout): 'bitmessagesettings', 'ackstealthlevel') from helper_ackPayload import genAckPayload ackdata = genAckPayload(streamNumber, stealthLevel) - # t = () - sqlExecute( - '''INSERT INTO sent VALUES - (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', - '', toAddress, ripe, fromAddress, subject, message, - ackdata, int(time.time()), int(time.time()), 0, - 'msgqueued', 0, 'sent', encoding, - BMConfigParser().getint( - 'bitmessagesettings', 'ttl')) + t = ( + '', + toAddress, + ripe, + fromAddress, + subject, + message, + ackdata, + int(time.time()), + int(time.time()), + 0, + 'msgqueued', + 0, + 'sent', + encoding, + BMConfigParser().getint('bitmessagesettings', 'ttl') + ) + helper_sent.insert(t) state.check_sent_acc = fromAddress state.msg_counter_objs = self.parent.parent.parent.parent\ .parent.parent.children[2].children[0].ids @@ -2253,12 +2263,24 @@ class Draft(Screen): 'bitmessagesettings', 'ackstealthlevel') from helper_ackPayload import genAckPayload ackdata = genAckPayload(streamNumber, stealthLevel) - sqlExecute( - '''INSERT INTO sent VALUES - (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '', toAddress, ripe, - fromAddress, subject, message, ackdata, int(time.time()), - int(time.time()), 0, 'msgqueued', 0, 'draft', encoding, - BMConfigParser().getint('bitmessagesettings', 'ttl')) + t = ( + '', + toAddress, + ripe, + fromAddress, + subject, + message, + ackdata, + int(time.time()), + int(time.time()), + 0, + 'msgqueued', + 0, + 'draft', + encoding, + BMConfigParser().getint('bitmessagesettings', 'ttl') + ) + helper_sent.insert(t) state.msg_counter_objs = src_object.children[2].children[0].ids state.draft_count = str(int(state.draft_count) + 1) src_object.ids.sc16.clear_widgets() diff --git a/src/helper_sent.py b/src/helper_sent.py index bc3362e8..60c4772d 100644 --- a/src/helper_sent.py +++ b/src/helper_sent.py @@ -2,9 +2,14 @@ Insert values into sent table """ +import uuid from helper_sql import sqlExecute def insert(t): """Perform an insert into the `sent` table""" + msgid = uuid.uuid4().bytes + temp = list(t) + temp[0] = msgid + t = tuple(temp) sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)