(self, params)
| 511 | return data |
| 512 | |
| 513 | def HandleGetInboxMessageById(self, params): |
| 514 | if len(params) == 0: |
| 515 | raise APIError(0, 'I need parameters!') |
| 516 | elif len(params) == 1: |
| 517 | msgid = self._decode(params[0], "hex") |
| 518 | elif len(params) >= 2: |
| 519 | msgid = self._decode(params[0], "hex") |
| 520 | readStatus = params[1] |
| 521 | if not isinstance(readStatus, bool): |
| 522 | raise APIError(23, 'Bool expected in readStatus, saw %s instead.' % type(readStatus)) |
| 523 | queryreturn = sqlQuery('''SELECT read FROM inbox WHERE msgid=?''', msgid) |
| 524 | # UPDATE is slow, only update if status is different |
| 525 | if queryreturn != [] and (queryreturn[0][0] == 1) != readStatus: |
| 526 | sqlExecute('''UPDATE inbox set read = ? WHERE msgid=?''', readStatus, msgid) |
| 527 | queues.UISignalQueue.put(('changedInboxUnread', None)) |
| 528 | queryreturn = sqlQuery('''SELECT msgid, toaddress, fromaddress, subject, received, message, encodingtype, read FROM inbox WHERE msgid=?''', msgid) |
| 529 | data = '{"inboxMessage":[' |
| 530 | for row in queryreturn: |
| 531 | msgid, toAddress, fromAddress, subject, received, message, encodingtype, read = row |
| 532 | subject = shared.fixPotentiallyInvalidUTF8Data(subject) |
| 533 | message = shared.fixPotentiallyInvalidUTF8Data(message) |
| 534 | data += json.dumps({'msgid':hexlify(msgid), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':base64.b64encode(subject), 'message':base64.b64encode(message), 'encodingType':encodingtype, 'receivedTime':received, 'read': read}, indent=4, separators=(',', ': ')) |
| 535 | data += ']}' |
| 536 | return data |
| 537 | |
| 538 | def HandleGetAllSentMessages(self, params): |
| 539 | queryreturn = sqlQuery('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent where folder='sent' ORDER BY lastactiontime''') |
nothing calls this directly
no test coverage detected