2020-09-25 05:17:08 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
2019-06-20 07:59:32 +00:00
|
|
|
|
2020-09-25 05:17:08 +00:00
|
|
|
Load the user's inbox and return it as a list
|
|
|
|
"""
|
2021-01-17 04:58:28 +00:00
|
|
|
from oldblocks import onionrblockapi
|
2020-09-25 05:17:08 +00:00
|
|
|
from coredb import blockmetadb
|
|
|
|
from utils import reconstructhash, identifyhome
|
|
|
|
import deadsimplekv as simplekv
|
|
|
|
"""
|
2019-06-20 07:59:32 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-09-25 05:17:08 +00:00
|
|
|
"""
|
|
|
|
|
2020-10-14 00:07:41 +00:00
|
|
|
inbox_cache = {}
|
2019-07-21 00:29:08 +00:00
|
|
|
def load_inbox():
|
2019-03-02 19:17:18 +00:00
|
|
|
inbox_list = []
|
2019-07-29 18:05:27 +00:00
|
|
|
deleted = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat').get('deleted_mail')
|
2019-03-02 19:17:18 +00:00
|
|
|
if deleted is None:
|
|
|
|
deleted = []
|
|
|
|
|
2019-07-17 16:25:29 +00:00
|
|
|
for blockHash in blockmetadb.get_blocks_by_type('pm'):
|
2020-10-14 00:07:41 +00:00
|
|
|
if blockHash in deleted:
|
|
|
|
continue
|
|
|
|
if blockHash in inbox_cache:
|
|
|
|
inbox_list.append(blockHash)
|
|
|
|
continue
|
2019-07-21 00:29:08 +00:00
|
|
|
block = onionrblockapi.Block(blockHash)
|
2019-03-02 19:17:18 +00:00
|
|
|
block.decrypt()
|
2020-10-14 00:07:41 +00:00
|
|
|
if block.decrypted and reconstructhash.deconstruct_hash(blockHash):
|
|
|
|
inbox_cache[blockHash] = True
|
2019-03-02 19:17:18 +00:00
|
|
|
inbox_list.append(blockHash)
|
2020-09-25 05:17:08 +00:00
|
|
|
return inbox_list
|