From b64bbda82aafa1eca09e225dc6fbc7cd458784eb Mon Sep 17 00:00:00 2001 From: Joshua Noble Date: Fri, 21 Jun 2013 00:54:11 -0400 Subject: [PATCH 1/3] Added folder to select statement for getInboxMessagesByAddress --- src/bitmessagemain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 79d1b6af..db4db315 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -4422,7 +4422,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): toAddress = params[0] v = (toAddress,) shared.sqlLock.acquire() - shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype FROM inbox WHERE toAddress=?''') + shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype FROM inbox WHERE folder='inbox' AND toAddress=?''') shared.sqlSubmitQueue.put(v) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() -- 2.45.1 From 894de2da34b95728d85153b5e7b6a0922f95d9c9 Mon Sep 17 00:00:00 2001 From: Joshua Noble Date: Fri, 21 Jun 2013 00:55:24 -0400 Subject: [PATCH 2/3] Changed received to receivedTime --- src/bitmessagemain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index db4db315..4279a259 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -4433,7 +4433,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): message = shared.fixPotentiallyInvalidUTF8Data(message) if len(data) > 25: data += ',' - data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'received':received},indent=4, separators=(',', ': ')) + data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'receivedTime':received},indent=4, separators=(',', ': ')) data += ']}' return data elif method == 'getSentMessageById': -- 2.45.1 From 37886916b8e5e08c0698ec575972cdf54db43397 Mon Sep 17 00:00:00 2001 From: Joshua Noble Date: Sat, 22 Jun 2013 02:21:24 -0400 Subject: [PATCH 3/3] Add getSentMessagesByAddress API command --- src/bitmessagemain.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 4279a259..c0b9c04e 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -4419,6 +4419,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): data += ']}' return data elif method == 'getInboxMessagesByAddress': + if len(params) == 0: + return 'API Error 0000: I need parameters!' toAddress = params[0] v = (toAddress,) shared.sqlLock.acquire() @@ -4454,6 +4456,26 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': ')) data += ']}' return data + elif method == 'getSentMessagesByAddress': + if len(params) == 0: + return 'API Error 0000: I need parameters!' + fromAddress = params[0] + v = (fromAddress,) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent WHERE folder='sent' AND fromAddress=? ORDER BY lastactiontime''') + shared.sqlSubmitQueue.put(v) + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + data = '{"sentMessages":[' + for row in queryreturn: + msgid, toAddress, fromAddress, subject, lastactiontime, message, encodingtype, status, ackdata = row + subject = shared.fixPotentiallyInvalidUTF8Data(subject) + message = shared.fixPotentiallyInvalidUTF8Data(message) + if len(data) > 25: + data += ',' + data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':encodingtype,'lastActionTime':lastactiontime,'status':status,'ackData':ackdata.encode('hex')},indent=4, separators=(',', ': ')) + data += ']}' + return data elif method == 'getSentMessageByAckData': if len(params) == 0: return 'API Error 0000: I need parameters!' -- 2.45.1