Only UPDATE readStatus if it changed

This commit is contained in:
Grant T. Olson 2013-09-07 13:31:17 -04:00
parent 0ad29c0e3c
commit 34203d73dd

View File

@ -414,7 +414,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
readStatus = params[1] readStatus = params[1]
if not isinstance(readStatus, bool): if not isinstance(readStatus, bool):
raise APIError(23, 'Bool expected in readStatus, saw %s instead.' % type(readStatus)) raise APIError(23, 'Bool expected in readStatus, saw %s instead.' % type(readStatus))
sqlExecute('''UPDATE inbox set read = ? WHERE msgid=?''', readStatus, msgid) queryreturn = sqlQuery('''SELECT read FROM inbox WHERE msgid=?''', msgid)
# UPDATE is slow, only update if status is different
if queryreturn != [] and (queryreturn[0][0] == 1) != readStatus:
sqlExecute('''UPDATE inbox set read = ? WHERE msgid=?''', readStatus, msgid)
queryreturn = sqlQuery('''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype, read FROM inbox WHERE msgid=?''', msgid) queryreturn = sqlQuery('''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype, read FROM inbox WHERE msgid=?''', msgid)
data = '{"inboxMessage":[' data = '{"inboxMessage":['
for row in queryreturn: for row in queryreturn: