Merge branch 'api_improvements' of git://github.com/DivineOmega/PyBitmessage into DivineOmega-api_improvements
This commit is contained in:
commit
0179fa0e4c
47
src/bitmessagemain.py
Executable file → Normal file
47
src/bitmessagemain.py
Executable file → Normal file
|
@ -4382,21 +4382,21 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
data += ']}'
|
||||
return data
|
||||
elif method == 'getInboxMessageById':
|
||||
if len(params) < 1:
|
||||
return 'API Error 0000: I need one parameter.'
|
||||
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 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)
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlLock.release()
|
||||
data = '{"inboxMessage":['
|
||||
for row in queryreturn:
|
||||
toAddress, fromAddress, subject, received, message, encodingtype = row
|
||||
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':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 += ']}'
|
||||
return data
|
||||
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 += ']}'
|
||||
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:
|
||||
return 'API Error 0000: I need parameters!'
|
||||
msgid = params[0].decode('hex')
|
||||
|
@ -4427,8 +4445,21 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
shared.UISignalQueue.put(('removeInboxRowByMsgid', msgid))
|
||||
return 'Trashed message (assuming message existed).'
|
||||
shared.UISignalQueue.put(('removeInboxRowByMsgid',msgid))
|
||||
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':
|
||||
if len(params) == 0:
|
||||
return 'API Error 0000: I need parameters!'
|
||||
|
|
Loading…
Reference in New Issue
Block a user