omitted unused code and optimized it
This commit is contained in:
parent
89254064f6
commit
beaece254c
11
src/api.py
11
src/api.py
|
@ -1117,9 +1117,8 @@ 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=toAddress, fromAddress=fromAddress,
|
||||||
subject=subject, message=message, ackdata=ackdata, encoding=encodingType,
|
subject=subject, message=message, encoding=encodingType)
|
||||||
ttl=TTL)
|
|
||||||
|
|
||||||
toLabel = ''
|
toLabel = ''
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
|
@ -1164,9 +1163,9 @@ class BMRPCDispatcher(object):
|
||||||
toAddress = str_broadcast_subscribers
|
toAddress = str_broadcast_subscribers
|
||||||
|
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
msgid='', toAddress=toAddress, fromAddress=fromAddress,
|
toAddress=toAddress, fromAddress=fromAddress,
|
||||||
status='broadcastqueued', subject=subject, message=message,
|
subject=subject, message=message, status='broadcastqueued',
|
||||||
ackdata=ackdata, encoding=encodingType, ttl=TTL)
|
encoding=encodingType)
|
||||||
|
|
||||||
toLabel = str_broadcast_subscribers
|
toLabel = str_broadcast_subscribers
|
||||||
queues.UISignalQueue.put(('displayNewSentMessage', (
|
queues.UISignalQueue.put(('displayNewSentMessage', (
|
||||||
|
|
|
@ -969,8 +969,7 @@ 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,
|
toAddress=addr, fromAddress=sender, subject=subject, message=body)
|
||||||
message=body, ackdata=ackdata)
|
|
||||||
queues.workerQueue.put(("sendmessage", addr))
|
queues.workerQueue.put(("sendmessage", addr))
|
||||||
else: # Broadcast
|
else: # Broadcast
|
||||||
if recv == "":
|
if recv == "":
|
||||||
|
@ -981,8 +980,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
||||||
recv = BROADCAST_STR
|
recv = BROADCAST_STR
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
msgid='', toAddress=recv, fromAddress=sender, subject=subject,
|
toAddress=recv, fromAddress=sender, subject=subject,
|
||||||
message=body, ackdata=ackdata, status='broadcastqueued')
|
message=body, status='broadcastqueued')
|
||||||
queues.workerQueue.put(('sendbroadcast', ''))
|
queues.workerQueue.put(('sendbroadcast', ''))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2167,8 +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=toAddress, fromAddress=fromAddress,
|
||||||
subject=subject, message=message, ackdata=ackdata, encoding=encoding)
|
subject=subject, message=message, encoding=encoding)
|
||||||
toLabel = ''
|
toLabel = ''
|
||||||
queryreturn = sqlQuery('''select label from addressbook where address=?''',
|
queryreturn = sqlQuery('''select label from addressbook where address=?''',
|
||||||
toAddress)
|
toAddress)
|
||||||
|
@ -2208,8 +2208,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
# msgid. We don't know what this will be until the POW is done.
|
# msgid. We don't know what this will be until the POW is done.
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
msgid='', toAddress=toAddress, fromAddress=fromAddress,
|
toAddress=toAddress, fromAddress=fromAddress,
|
||||||
subject=subject, message=message, ackdata=ackdata,
|
subject=subject, message=message,
|
||||||
status='broadcastqueued', encoding=encoding)
|
status='broadcastqueued', encoding=encoding)
|
||||||
|
|
||||||
toLabel = str_broadcast_subscribers
|
toLabel = str_broadcast_subscribers
|
||||||
|
|
|
@ -749,22 +749,14 @@ class objectProcessor(threading.Thread):
|
||||||
|
|
||||||
ackdata = genAckPayload(streamNumber, 0)
|
ackdata = genAckPayload(streamNumber, 0)
|
||||||
toAddress = '[Broadcast subscribers]'
|
toAddress = '[Broadcast subscribers]'
|
||||||
ripe = ''
|
|
||||||
|
|
||||||
# We really should have a discussion about how to
|
|
||||||
# set the TTL for mailing list broadcasts. This is obviously
|
|
||||||
# hard-coded.
|
|
||||||
TTL = 2 * 7 * 24 * 60 * 60 # 2 weeks
|
|
||||||
helper_sent.insert(
|
helper_sent.insert(
|
||||||
msgid='',
|
|
||||||
toAddress=toAddress,
|
toAddress=toAddress,
|
||||||
fromAddress=fromAddress,
|
fromAddress=fromAddress,
|
||||||
status='broadcastqueued',
|
status='broadcastqueued',
|
||||||
subject=subject,
|
subject=subject,
|
||||||
message=message,
|
message=message,
|
||||||
ackdata=ackdata,
|
encoding=messageEncodingType)
|
||||||
encoding=messageEncodingType,
|
|
||||||
ttl=TTL)
|
|
||||||
|
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'displayNewSentMessage', (
|
'displayNewSentMessage', (
|
||||||
|
|
|
@ -13,8 +13,7 @@ from helper_sql import sqlExecute
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=None,
|
def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=None,
|
||||||
status=None, ripe=None, ackdata=None, sentTime=None, lastActionTime=None,
|
status=None, ripe=None, ackdata=None, sentTime=None, lastActionTime=None,
|
||||||
sleeptill=None, retryNumber=None, encoding=None, ttl=None, folder='sent',
|
sleeptill=0, retryNumber=0, encoding=2, 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
|
||||||
|
@ -35,11 +34,7 @@ def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=N
|
||||||
sentTime = sentTime if sentTime else int(time.time()) # sentTime (this doesn't change)
|
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 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
|
|
||||||
encoding = encoding if encoding else 2
|
|
||||||
|
|
||||||
ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl')
|
ttl = ttl if ttl else BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||||
|
|
||||||
t = (msgid, toAddress, ripe, fromAddress, subject, message, ackdata,
|
t = (msgid, toAddress, ripe, fromAddress, subject, message, ackdata,
|
||||||
|
@ -47,4 +42,4 @@ def insert(msgid=None, toAddress=None, fromAddress=None, subject=None, message=N
|
||||||
encoding, ttl)
|
encoding, ttl)
|
||||||
|
|
||||||
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
||||||
return t if is_testcase else None
|
return msgid
|
||||||
|
|
|
@ -246,26 +246,12 @@ class TestCore(unittest.TestCase):
|
||||||
toAddress = 'BM-2cVWtdUzPwF7UNGDrZftWuHWgjdfkj89fdf'
|
toAddress = 'BM-2cVWtdUzPwF7UNGDrZftWuHWgjdfkj89fdf'
|
||||||
message = 'test message'
|
message = 'test message'
|
||||||
subject = 'test subject'
|
subject = 'test subject'
|
||||||
encoding = 2
|
|
||||||
status = 'msgqueued'
|
status = 'msgqueued'
|
||||||
result = helper_sent.insert(
|
|
||||||
msgid='', toAddress=toAddress, fromAddress=fromAddress,
|
|
||||||
subject=subject, message=message, status=status, encoding=encoding,
|
|
||||||
is_testcase=True
|
|
||||||
)
|
|
||||||
self.assertNotEqual(result[0], '')
|
|
||||||
|
|
||||||
def test_defalut_insert_values(self):
|
|
||||||
"""Test missing values in insert method for message sending"""
|
|
||||||
fromAddress = 'BM-2cTrmD22fLRrumi3pPLg1ELJ6PdAaTRTdfg'
|
|
||||||
toAddress = 'BM-2cVWtdUzPwF7UNGDrZftWuHWiJ6xxBpiSP' # autoresponder address
|
|
||||||
message = 'test message'
|
|
||||||
subject = 'test subject'
|
|
||||||
result = helper_sent.insert(
|
result = helper_sent.insert(
|
||||||
toAddress=toAddress, fromAddress=fromAddress, subject=subject,
|
toAddress=toAddress, fromAddress=fromAddress, subject=subject,
|
||||||
message=message, is_testcase=True)
|
message=message, status=status,
|
||||||
for index in [0, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14]:
|
)
|
||||||
self.assertNotEqual(result[index], '')
|
self.assertNotEqual(result, '')
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user