fixed default variables in insert method
This commit is contained in:
parent
5eff9d6a04
commit
89254064f6
37
src/api.py
37
src/api.py
|
@ -1117,21 +1117,9 @@ class BMRPCDispatcher(object):
|
||||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
|
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'',
|
msgid='', toAddress=toAddress, ripe=toRipe, fromAddress=fromAddress,
|
||||||
toAddress,
|
subject=subject, message=message, ackdata=ackdata, encoding=encodingType,
|
||||||
toRipe,
|
ttl=TTL)
|
||||||
fromAddress,
|
|
||||||
subject,
|
|
||||||
message,
|
|
||||||
ackdata,
|
|
||||||
int(time.time()), # sentTime (this won't change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0,
|
|
||||||
'msgqueued',
|
|
||||||
0,
|
|
||||||
'sent',
|
|
||||||
encodingType,
|
|
||||||
TTL)
|
|
||||||
|
|
||||||
toLabel = ''
|
toLabel = ''
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
|
@ -1174,24 +1162,11 @@ class BMRPCDispatcher(object):
|
||||||
streamNumber = decodeAddress(fromAddress)[2]
|
streamNumber = decodeAddress(fromAddress)[2]
|
||||||
ackdata = genAckPayload(streamNumber, 0)
|
ackdata = genAckPayload(streamNumber, 0)
|
||||||
toAddress = str_broadcast_subscribers
|
toAddress = str_broadcast_subscribers
|
||||||
ripe = ''
|
|
||||||
|
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'',
|
msgid='', toAddress=toAddress, fromAddress=fromAddress,
|
||||||
toAddress,
|
status='broadcastqueued', subject=subject, message=message,
|
||||||
ripe,
|
ackdata=ackdata, encoding=encodingType, ttl=TTL)
|
||||||
fromAddress,
|
|
||||||
subject,
|
|
||||||
message,
|
|
||||||
ackdata,
|
|
||||||
int(time.time()), # sentTime (this doesn't change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0,
|
|
||||||
'broadcastqueued',
|
|
||||||
0,
|
|
||||||
'sent',
|
|
||||||
encodingType,
|
|
||||||
TTL)
|
|
||||||
|
|
||||||
toLabel = str_broadcast_subscribers
|
toLabel = str_broadcast_subscribers
|
||||||
queues.UISignalQueue.put(('displayNewSentMessage', (
|
queues.UISignalQueue.put(('displayNewSentMessage', (
|
||||||
|
|
|
@ -969,22 +969,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
||||||
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
|
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'',
|
msgid='', toAddress=addr, ripe=ripe, fromAddress=sender, subject=subject,
|
||||||
addr,
|
message=body, ackdata=ackdata)
|
||||||
ripe,
|
|
||||||
sender,
|
|
||||||
subject,
|
|
||||||
body,
|
|
||||||
ackdata,
|
|
||||||
int(time.time()), # sentTime (this will never change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0, # sleepTill time. This will get set when the POW gets done.
|
|
||||||
"msgqueued",
|
|
||||||
0, # retryNumber
|
|
||||||
"sent",
|
|
||||||
2, # encodingType
|
|
||||||
0
|
|
||||||
)
|
|
||||||
queues.workerQueue.put(("sendmessage", addr))
|
queues.workerQueue.put(("sendmessage", addr))
|
||||||
else: # Broadcast
|
else: # Broadcast
|
||||||
if recv == "":
|
if recv == "":
|
||||||
|
@ -994,24 +980,9 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
# dummy ackdata, no need for stealth
|
# dummy ackdata, no need for stealth
|
||||||
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
||||||
recv = BROADCAST_STR
|
recv = BROADCAST_STR
|
||||||
ripe = ""
|
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'',
|
msgid='', toAddress=recv, fromAddress=sender, subject=subject,
|
||||||
recv,
|
message=body, ackdata=ackdata, status='broadcastqueued')
|
||||||
ripe,
|
|
||||||
sender,
|
|
||||||
subject,
|
|
||||||
body,
|
|
||||||
ackdata,
|
|
||||||
int(time.time()), # sentTime (this will never change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0, # sleepTill time. This will get set when the POW gets done.
|
|
||||||
"broadcastqueued",
|
|
||||||
0, # retryNumber
|
|
||||||
"sent", # folder
|
|
||||||
2, # encodingType
|
|
||||||
0
|
|
||||||
)
|
|
||||||
queues.workerQueue.put(('sendbroadcast', ''))
|
queues.workerQueue.put(('sendbroadcast', ''))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2167,22 +2167,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
'bitmessagesettings', 'ackstealthlevel')
|
'bitmessagesettings', 'ackstealthlevel')
|
||||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'',
|
msgid='', toAddress=toAddress, ripe=ripe, fromAddress=fromAddress,
|
||||||
toAddress,
|
subject=subject, message=message, ackdata=ackdata, encoding=encoding)
|
||||||
ripe,
|
|
||||||
fromAddress,
|
|
||||||
subject,
|
|
||||||
message,
|
|
||||||
ackdata,
|
|
||||||
int(time.time()), # sentTime (this will never change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0, # sleepTill time. This will get set when the POW gets done.
|
|
||||||
'msgqueued',
|
|
||||||
0, # retryNumber
|
|
||||||
'sent', # folder
|
|
||||||
encoding, # encodingtype
|
|
||||||
0
|
|
||||||
)
|
|
||||||
toLabel = ''
|
toLabel = ''
|
||||||
queryreturn = sqlQuery('''select label from addressbook where address=?''',
|
queryreturn = sqlQuery('''select label from addressbook where address=?''',
|
||||||
toAddress)
|
toAddress)
|
||||||
|
@ -2219,24 +2205,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
streamNumber = decodeAddress(fromAddress)[2]
|
streamNumber = decodeAddress(fromAddress)[2]
|
||||||
ackdata = genAckPayload(streamNumber, 0)
|
ackdata = genAckPayload(streamNumber, 0)
|
||||||
toAddress = str_broadcast_subscribers
|
toAddress = str_broadcast_subscribers
|
||||||
ripe = ''
|
|
||||||
|
# msgid. We don't know what this will be until the POW is done.
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'', # msgid. We don't know what this will be until the POW is done.
|
msgid='', toAddress=toAddress, fromAddress=fromAddress,
|
||||||
toAddress,
|
subject=subject, message=message, ackdata=ackdata,
|
||||||
ripe,
|
status='broadcastqueued', encoding=encoding)
|
||||||
fromAddress,
|
|
||||||
subject,
|
|
||||||
message,
|
|
||||||
ackdata,
|
|
||||||
int(time.time()), # sentTime (this will never change)
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0, # sleepTill time. This will get set when the POW gets done.
|
|
||||||
'broadcastqueued',
|
|
||||||
0, # retryNumber
|
|
||||||
'sent', # folder
|
|
||||||
encoding, # encoding type
|
|
||||||
0
|
|
||||||
)
|
|
||||||
|
|
||||||
toLabel = str_broadcast_subscribers
|
toLabel = str_broadcast_subscribers
|
||||||
|
|
||||||
|
|
|
@ -756,21 +756,15 @@ class objectProcessor(threading.Thread):
|
||||||
# hard-coded.
|
# hard-coded.
|
||||||
TTL = 2 * 7 * 24 * 60 * 60 # 2 weeks
|
TTL = 2 * 7 * 24 * 60 * 60 # 2 weeks
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
'',
|
msgid='',
|
||||||
toAddress,
|
toAddress=toAddress,
|
||||||
ripe,
|
fromAddress=fromAddress,
|
||||||
fromAddress,
|
status='broadcastqueued',
|
||||||
subject,
|
subject=subject,
|
||||||
message,
|
message=message,
|
||||||
ackdata,
|
ackdata=ackdata,
|
||||||
int(time.time()), # sentTime (this doesn't change)
|
encoding=messageEncodingType,
|
||||||
int(time.time()), # lastActionTime
|
ttl=TTL)
|
||||||
0,
|
|
||||||
'broadcastqueued',
|
|
||||||
0,
|
|
||||||
'sent',
|
|
||||||
messageEncodingType,
|
|
||||||
TTL)
|
|
||||||
|
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'displayNewSentMessage', (
|
'displayNewSentMessage', (
|
||||||
|
|
|
@ -11,9 +11,10 @@ from helper_sql import sqlExecute
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def insert(msgid, toAddress, ripe, fromAddress, subject, message, ackdata,
|
def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=None,
|
||||||
sentTime, lastActionTime, sleeptill=0, status='msgqueued',
|
status=None, ripe=None, ackdata=None, sentTime=None, lastActionTime=None,
|
||||||
retryNumber=0, folder='sent', encoding=2, ttl=0, is_testcase=False):
|
sleeptill=None, retryNumber=None, encoding=None, ttl=None, folder='sent',
|
||||||
|
is_testcase=False):
|
||||||
"""Perform an insert into the `sent` table"""
|
"""Perform an insert into the `sent` table"""
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
# pylint: disable-msg=too-many-locals
|
# pylint: disable-msg=too-many-locals
|
||||||
|
@ -31,13 +32,12 @@ def insert(msgid, toAddress, ripe, fromAddress, subject, message, ackdata,
|
||||||
new_ackdata = genAckPayload(streamNumber, stealthLevel)
|
new_ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
ackdata = new_ackdata
|
ackdata = new_ackdata
|
||||||
|
|
||||||
sentTime = sentTime if sentTime else int(time.time())
|
sentTime = sentTime if sentTime else int(time.time()) # sentTime (this doesn't change)
|
||||||
lastActionTime = lastActionTime if lastActionTime else int(time.time())
|
lastActionTime = lastActionTime if lastActionTime else int(time.time())
|
||||||
|
|
||||||
sleeptill = sleeptill if sleeptill else 0
|
sleeptill = sleeptill if sleeptill else 0 # sleepTill time. This will get set when the POW gets done.
|
||||||
status = status if status else 'msgqueued'
|
status = status if status else 'msgqueued'
|
||||||
retryNumber = retryNumber if retryNumber else 0
|
retryNumber = retryNumber if retryNumber else 0
|
||||||
folder = folder if folder else 'sent'
|
|
||||||
encoding = encoding if encoding else 2
|
encoding = encoding if encoding else 2
|
||||||
|
|
||||||
ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl')
|
ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||||
|
|
|
@ -247,23 +247,12 @@ class TestCore(unittest.TestCase):
|
||||||
message = 'test message'
|
message = 'test message'
|
||||||
subject = 'test subject'
|
subject = 'test subject'
|
||||||
encoding = 2
|
encoding = 2
|
||||||
|
status = 'msgqueued'
|
||||||
result = helper_sent.insert(
|
result = helper_sent.insert(
|
||||||
'', # msgid
|
msgid='', toAddress=toAddress, fromAddress=fromAddress,
|
||||||
toAddress,
|
subject=subject, message=message, status=status, encoding=encoding,
|
||||||
'', # ripe
|
is_testcase=True
|
||||||
fromAddress,
|
)
|
||||||
subject,
|
|
||||||
message,
|
|
||||||
'', # ackdata
|
|
||||||
int(time.time()), # sentTime
|
|
||||||
int(time.time()), # lastActionTime
|
|
||||||
0, # sleeptill
|
|
||||||
'msgqueued',
|
|
||||||
0,
|
|
||||||
'sent',
|
|
||||||
encoding,
|
|
||||||
0,
|
|
||||||
True)
|
|
||||||
self.assertNotEqual(result[0], '')
|
self.assertNotEqual(result[0], '')
|
||||||
|
|
||||||
def test_defalut_insert_values(self):
|
def test_defalut_insert_values(self):
|
||||||
|
@ -273,22 +262,8 @@ class TestCore(unittest.TestCase):
|
||||||
message = 'test message'
|
message = 'test message'
|
||||||
subject = 'test subject'
|
subject = 'test subject'
|
||||||
result = helper_sent.insert(
|
result = helper_sent.insert(
|
||||||
'', # msgid
|
toAddress=toAddress, fromAddress=fromAddress, subject=subject,
|
||||||
toAddress,
|
message=message, is_testcase=True)
|
||||||
'', # ripe
|
|
||||||
fromAddress,
|
|
||||||
subject,
|
|
||||||
message,
|
|
||||||
'', # ackdata
|
|
||||||
'', # sentTime
|
|
||||||
'', # lastActionTime
|
|
||||||
'', # sleeptill
|
|
||||||
'', # status
|
|
||||||
'', # retryNumber
|
|
||||||
'', # folder
|
|
||||||
'', # encoding
|
|
||||||
'',
|
|
||||||
True)
|
|
||||||
for index in [0, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14]:
|
for index in [0, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14]:
|
||||||
self.assertNotEqual(result[index], '')
|
self.assertNotEqual(result[index], '')
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user