Merge branch 'api_improvements' of git://github.com/DivineOmega/PyBitmessage into DivineOmega-api_improvements
This commit is contained in:
commit
0179fa0e4c
45
src/bitmessagemain.py
Executable file → Normal file
45
src/bitmessagemain.py
Executable file → Normal file
|
@ -4382,21 +4382,21 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
data += ']}'
|
data += ']}'
|
||||||
return data
|
return data
|
||||||
elif method == 'getInboxMessageById':
|
elif method == 'getInboxMessageById':
|
||||||
if len(params) < 1:
|
if len(params) == 0:
|
||||||
return 'API Error 0000: I need one parameter.'
|
return 'API Error 0000: I need parameters!'
|
||||||
msgid = params[0].decode('hex')
|
msgid = params[0].decode('hex')
|
||||||
v = (msgid,)
|
v = (msgid,)
|
||||||
shared.sqlLock.acquire()
|
shared.sqlLock.acquire()
|
||||||
shared.sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, received, message, encodingtype FROM inbox WHERE msgid=?''')
|
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message FROM inbox WHERE msgid=?''')
|
||||||
shared.sqlSubmitQueue.put(v)
|
shared.sqlSubmitQueue.put(v)
|
||||||
queryreturn = shared.sqlReturnQueue.get()
|
queryreturn = shared.sqlReturnQueue.get()
|
||||||
shared.sqlLock.release()
|
shared.sqlLock.release()
|
||||||
data = '{"inboxMessage":['
|
data = '{"inboxMessage":['
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
toAddress, fromAddress, subject, received, message, encodingtype = row
|
msgid, toAddress, fromAddress, subject, received, message, = row
|
||||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||||
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 += 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 += ']}'
|
data += ']}'
|
||||||
return data
|
return data
|
||||||
elif method == 'getAllSentMessages':
|
elif method == 'getAllSentMessages':
|
||||||
|
@ -4415,7 +4415,25 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':2,'lastActionTime':lastactiontime,'status':status},indent=4, separators=(',', ': '))
|
data += json.dumps({'msgid':msgid.encode('hex'),'toAddress':toAddress,'fromAddress':fromAddress,'subject':subject.encode('base64'),'message':message.encode('base64'),'encodingType':2,'lastActionTime':lastactiontime,'status':status},indent=4, separators=(',', ': '))
|
||||||
data += ']}'
|
data += ']}'
|
||||||
return data
|
return data
|
||||||
elif method == 'trashMessage':
|
elif method == 'getSentMessageById':
|
||||||
|
if len(params) == 0:
|
||||||
|
return 'API Error 0000: I need parameters!'
|
||||||
|
msgid = params[0].decode('hex')
|
||||||
|
v = (msgid,)
|
||||||
|
shared.sqlLock.acquire()
|
||||||
|
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, status FROM sent WHERE msgid=?''')
|
||||||
|
shared.sqlSubmitQueue.put(v)
|
||||||
|
queryreturn = shared.sqlReturnQueue.get()
|
||||||
|
shared.sqlLock.release()
|
||||||
|
data = '{"sentMessage":['
|
||||||
|
for row in queryreturn:
|
||||||
|
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,'lastActionTime':lastactiontime},indent=4, separators=(',', ': '))
|
||||||
|
data += ']}'
|
||||||
|
return data
|
||||||
|
elif (method == 'trashMessage') or (method == 'trashInboxMessage'):
|
||||||
if len(params) == 0:
|
if len(params) == 0:
|
||||||
return 'API Error 0000: I need parameters!'
|
return 'API Error 0000: I need parameters!'
|
||||||
msgid = params[0].decode('hex')
|
msgid = params[0].decode('hex')
|
||||||
|
@ -4428,7 +4446,20 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
shared.sqlSubmitQueue.put('commit')
|
shared.sqlSubmitQueue.put('commit')
|
||||||
shared.sqlLock.release()
|
shared.sqlLock.release()
|
||||||
shared.UISignalQueue.put(('removeInboxRowByMsgid',msgid))
|
shared.UISignalQueue.put(('removeInboxRowByMsgid',msgid))
|
||||||
return 'Trashed message (assuming message existed).'
|
return 'Trashed inbox message (assuming message existed).'
|
||||||
|
elif method == 'trashSentMessage':
|
||||||
|
if len(params) == 0:
|
||||||
|
return 'API Error 0000: I need parameters!'
|
||||||
|
msgid = params[0].decode('hex')
|
||||||
|
t = (msgid,)
|
||||||
|
shared.sqlLock.acquire()
|
||||||
|
shared.sqlSubmitQueue.put('''UPDATE sent SET folder='trash' WHERE msgid=?''')
|
||||||
|
shared.sqlSubmitQueue.put(t)
|
||||||
|
shared.sqlReturnQueue.get()
|
||||||
|
shared.sqlSubmitQueue.put('commit')
|
||||||
|
shared.sqlLock.release()
|
||||||
|
shared.UISignalQueue.put(('removeSentRowByMsgid',msgid))
|
||||||
|
return 'Trashed sent message (assuming message existed).'
|
||||||
elif method == 'sendMessage':
|
elif method == 'sendMessage':
|
||||||
if len(params) == 0:
|
if len(params) == 0:
|
||||||
return 'API Error 0000: I need parameters!'
|
return 'API Error 0000: I need parameters!'
|
||||||
|
|
Reference in New Issue
Block a user