When using API, start giving user actual message encoding type now that the inbox table actually tracks it
This commit is contained in:
parent
461a49f99f
commit
28f9144113
|
@ -4366,35 +4366,37 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
elif method == 'getAllInboxMessages':
|
elif method == 'getAllInboxMessages':
|
||||||
shared.sqlLock.acquire()
|
shared.sqlLock.acquire()
|
||||||
shared.sqlSubmitQueue.put(
|
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('')
|
shared.sqlSubmitQueue.put('')
|
||||||
queryreturn = shared.sqlReturnQueue.get()
|
queryreturn = shared.sqlReturnQueue.get()
|
||||||
shared.sqlLock.release()
|
shared.sqlLock.release()
|
||||||
data = '{"inboxMessages":['
|
data = '{"inboxMessages":['
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
msgid, toAddress, fromAddress, subject, received, message, = row
|
msgid, toAddress, fromAddress, subject, received, message, encodingtype = row
|
||||||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||||
if len(data) > 25:
|
if len(data) > 25:
|
||||||
data += ','
|
data += ','
|
||||||
data += json.dumps({'msgid': msgid.encode('hex'), 'toAddress': toAddress, 'fromAddress': fromAddress, 'subject': subject.encode(
|
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 += ']}'
|
data += ']}'
|
||||||
return data
|
return data
|
||||||
elif method == 'getInboxMessageById':
|
elif method == 'getInboxMessageById':
|
||||||
|
if len(params) < 1:
|
||||||
|
return 'API Error 0000: I need one parameter.'
|
||||||
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 FROM inbox WHERE msgid=?''')
|
shared.sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, received, message, encodingtype 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, = row
|
toAddress, fromAddress, subject, received, message, encodingtype = 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':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 += ']}'
|
data += ']}'
|
||||||
return data
|
return data
|
||||||
elif method == 'trashMessage':
|
elif method == 'trashMessage':
|
||||||
|
|
Reference in New Issue
Block a user