This repository has been archived on 2024-12-03. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-03/src/helper_inbox.py

38 lines
1.2 KiB
Python
Raw Normal View History

2019-10-07 10:08:26 +02:00
"""Helper Inbox performs inbox messages related operations"""
2018-04-07 12:41:24 +02:00
import queues
2019-10-07 16:17:40 +02:00
from helper_sql import sqlExecute, sqlQuery
from dbcompat import dbstr
2018-04-07 12:41:24 +02:00
def insert(t):
2019-10-07 10:08:26 +02:00
"""Perform an insert into the "inbox" table"""
u = [t[0], dbstr(t[1]), dbstr(t[2]), dbstr(t[3]), dbstr(t[4]), dbstr(t[5]), dbstr(t[6]), t[7], t[8], t[9]]
sqlExecute('''INSERT INTO inbox VALUES (?,?,?,?,?,?,?,?,?,?)''', *u)
2018-04-07 12:41:24 +02:00
# shouldn't emit changedInboxUnread and displayNewInboxMessage
# at the same time
# queues.UISignalQueue.put(('changedInboxUnread', None))
def trash(msgid):
2019-10-07 16:17:40 +02:00
"""Mark a message in the `inbox` as `trash`"""
2013-08-27 14:13:40 +02:00
sqlExecute('''UPDATE inbox SET folder='trash' WHERE msgid=?''', msgid)
2018-04-07 12:41:24 +02:00
queues.UISignalQueue.put(('removeInboxRowByMsgid', msgid))
2022-07-07 17:47:40 +02:00
def delete(ack_data):
"""Permanent delete message from trash"""
sqlExecute("DELETE FROM inbox WHERE msgid = ?", ack_data)
def undeleteMessage(msgid):
"""Undelte the message"""
sqlExecute('''UPDATE inbox SET folder='inbox' WHERE msgid=?''', msgid)
def isMessageAlreadyInInbox(sigHash):
2019-10-07 16:17:40 +02:00
"""Check for previous instances of this message"""
2014-07-26 19:15:28 +02:00
queryReturn = sqlQuery(
'''SELECT COUNT(*) FROM inbox WHERE sighash=?''', sigHash)
return queryReturn[0][0] != 0