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

36 lines
1.1 KiB
Python
Raw Normal View History

2019-10-07 13:38:26 +05:30
"""Helper Inbox performs inbox messages related operations"""
2018-04-07 16:11:24 +05:30
import queues
2019-10-07 19:47:40 +05:30
from helper_sql import sqlExecute, sqlQuery
2018-04-07 16:11:24 +05:30
def insert(t):
2019-10-07 13:38:26 +05:30
"""Perform an insert into the "inbox" table"""
sqlExecute('''INSERT INTO inbox VALUES (?,?,?,?,?,?,?,?,?,?)''', *t)
2018-04-07 16:11:24 +05:30
# shouldn't emit changedInboxUnread and displayNewInboxMessage
# at the same time
# queues.UISignalQueue.put(('changedInboxUnread', None))
def trash(msgid):
2019-10-07 19:47:40 +05:30
"""Mark a message in the `inbox` as `trash`"""
2013-08-27 08:13:40 -04:00
sqlExecute('''UPDATE inbox SET folder='trash' WHERE msgid=?''', msgid)
2018-04-07 16:11:24 +05:30
queues.UISignalQueue.put(('removeInboxRowByMsgid', msgid))
2022-07-07 21:17:40 +05:30
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 19:47:40 +05:30
"""Check for previous instances of this message"""
2014-07-26 13:15:28 -04:00
queryReturn = sqlQuery(
'''SELECT COUNT(*) FROM inbox WHERE sighash=?''', sigHash)
return queryReturn[0][0] != 0