From 3f07f895bc1389f630bc393ecd5aafcf0db41e34 Mon Sep 17 00:00:00 2001 From: "jordan@hall05.co.uk" <1337One> Date: Wed, 19 Jun 2013 12:06:46 +0000 Subject: [PATCH] Added 'getAllInboxMessages' command to API. --- src/bitmessagemain.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 7397fbb5..346d8a66 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -3696,6 +3696,22 @@ 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 == 'getInboxMessageById': + msgid = params[0].decode('hex') + v = (msgid,) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message FROM inbox WHERE msgid=?''') + shared.sqlSubmitQueue.put(v) + queryreturn = shared.sqlReturnQueue.get() + shared.sqlLock.release() + data = '{"inboxMessage":[' + for row in queryreturn: + msgid, toAddress, fromAddress, subject, received, message, = row + subject = shared.fixPotentiallyInvalidUTF8Data(subject) + message = shared.fixPotentiallyInvalidUTF8Data(message) + 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 == 'getAllSentMessages': shared.sqlLock.acquire() shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, status FROM sent where folder='sent' ORDER BY lastactiontime''')