From 28f91441134460480c2880c306f9f6450c1ac892 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 18 Jun 2013 13:24:35 -0400 Subject: [PATCH] When using API, start giving user actual message encoding type now that the inbox table actually tracks it --- src/bitmessagemain.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 33d815d8..be2fdf48 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -4366,35 +4366,37 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): elif method == 'getAllInboxMessages': shared.sqlLock.acquire() shared.sqlSubmitQueue.put( - '''SELECT msgid, toaddress, fromaddress, subject, received, message FROM inbox where folder='inbox' ORDER BY received''') + '''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype FROM inbox where folder='inbox' ORDER BY received''') shared.sqlSubmitQueue.put('') queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() data = '{"inboxMessages":[' for row in queryreturn: - msgid, toAddress, fromAddress, subject, received, message, = row + msgid, toAddress, fromAddress, subject, received, message, encodingtype = 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=(',', ': ')) + 'base64'), 'message': message.encode('base64'), 'encodingType': encodingtype, 'receivedTime': received}, indent=4, separators=(',', ': ')) data += ']}' return data elif method == 'getInboxMessageById': + if len(params) < 1: + return 'API Error 0000: I need one parameter.' msgid = params[0].decode('hex') v = (msgid,) shared.sqlLock.acquire() - shared.sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, received, message FROM inbox WHERE msgid=?''') + shared.sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, received, message, encodingtype FROM inbox WHERE msgid=?''') shared.sqlSubmitQueue.put(v) queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() data = '{"inboxMessage":[' for row in queryreturn: - toAddress, fromAddress, subject, received, message, = row + toAddress, fromAddress, subject, received, message, encodingtype = 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 += 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 == 'trashMessage':