removed the inset sent query and using the comman helper_sent.inset method for data insertion

This commit is contained in:
navjot 2020-09-15 22:13:22 +05:30
parent e0eb795696
commit 8850a68347
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
2 changed files with 42 additions and 15 deletions

View File

@ -62,6 +62,7 @@ from uikivysignaler import UIkivySignaler
import identiconGeneration import identiconGeneration
from addresses import addBMIfNotPresent, decodeAddress from addresses import addBMIfNotPresent, decodeAddress
import helper_sent
def toast(text): def toast(text):
@ -606,15 +607,24 @@ class DropDownWidget(BoxLayout):
'bitmessagesettings', 'ackstealthlevel') 'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
# t = () t = (
sqlExecute( '',
'''INSERT INTO sent VALUES toAddress,
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', ripe,
'', toAddress, ripe, fromAddress, subject, message, fromAddress,
ackdata, int(time.time()), int(time.time()), 0, subject,
'msgqueued', 0, 'sent', encoding, message,
BMConfigParser().getint( ackdata,
'bitmessagesettings', 'ttl')) 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.check_sent_acc = fromAddress
state.msg_counter_objs = self.parent.parent.parent.parent\ state.msg_counter_objs = self.parent.parent.parent.parent\
.parent.parent.children[2].children[0].ids .parent.parent.children[2].children[0].ids
@ -2253,12 +2263,24 @@ class Draft(Screen):
'bitmessagesettings', 'ackstealthlevel') 'bitmessagesettings', 'ackstealthlevel')
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
sqlExecute( t = (
'''INSERT INTO sent VALUES '',
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '', toAddress, ripe, toAddress,
fromAddress, subject, message, ackdata, int(time.time()), ripe,
int(time.time()), 0, 'msgqueued', 0, 'draft', encoding, fromAddress,
BMConfigParser().getint('bitmessagesettings', 'ttl')) 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.msg_counter_objs = src_object.children[2].children[0].ids
state.draft_count = str(int(state.draft_count) + 1) state.draft_count = str(int(state.draft_count) + 1)
src_object.ids.sc16.clear_widgets() src_object.ids.sc16.clear_widgets()

View File

@ -2,9 +2,14 @@
Insert values into sent table Insert values into sent table
""" """
import uuid
from helper_sql import sqlExecute from helper_sql import sqlExecute
def insert(t): def insert(t):
"""Perform an insert into the `sent` table""" """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) sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)