From c655b9a50602c4e5288b6ee29b30b88525f5ce91 Mon Sep 17 00:00:00 2001 From: Joshua Noble Date: Thu, 20 Jun 2013 00:49:28 -0400 Subject: [PATCH] Add getInboxMessagesByAddress API command --- src/bitmessagemain.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index e347d561..6b778a97 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -3712,6 +3712,24 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':2,'receivedTime':received},indent=4, separators=(',', ': ')) data += ']}' return data + elif method == 'getInboxMessagesByAddress': + toAddress = params[0] + v = (toAddress,) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''SELECT msgid, fromaddress, subject, received, message FROM inbox WHERE toAddress=?''') + shared.sqlSubmitQueue.put(v) + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + data = '{"inboxMessages":[' + for row in queryreturn: + msgid, fromAddress, subject, received, message, = 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':2,'receivedTime':received},indent=4, separators=(',', ': ')) + data += ']}' + return data elif method == 'trashMessage': if len(params) == 0: return 'API Error 0000: I need parameters!'