work on mail settings

master
Kevin Froman 2020-02-25 20:30:04 -06:00
parent 6f0ef390a7
commit 862c6f2ea4
5 changed files with 11 additions and 9 deletions

View File

@ -117,6 +117,7 @@ def download_blocks_from_communicator(comm_inst: "OnionrCommunicatorDaemon"):
removeFromQueue = False
else:
blockmetadb.add_to_block_DB(blockHash, dataSaved=True) # add block to meta db
blockmetadata.process_block_metadata(blockHash) # caches block metadata values to block database
spawn(
local_command,
f'/daemon-event/upload_event',
@ -124,8 +125,6 @@ def download_blocks_from_communicator(comm_inst: "OnionrCommunicatorDaemon"):
is_json=True,
postData={'block': blockHash}
)
blockmetadata.process_block_metadata(blockHash) # caches block metadata values to block database
else:
logger.warn('POW failed for block %s.' % (blockHash,))
else:

View File

@ -31,14 +31,14 @@ from onionrutils import updater
def process_block_metadata(blockHash: str):
'''
Read metadata from a block and cache it to the block database
blockHash -> sha3_256 hex formatted hash of Onionr block
'''
curTime = epoch.get_rounded_epoch(roundS=60)
myBlock = onionrblockapi.Block(blockHash)
if myBlock.isEncrypted:
myBlock.decrypt()
if (myBlock.isEncrypted and myBlock.decrypted) or (not myBlock.isEncrypted):
print(myBlock.hash, myBlock.decrypt())
if myBlock.decrypted or not myBlock.isEncrypted:
blockType = myBlock.getMetadata('type') # we would use myBlock.getType() here, but it is bugged with encrypted blocks
signer = bytesconverter.bytes_to_str(myBlock.signer)
@ -49,7 +49,7 @@ def process_block_metadata(blockHash: str):
onionrusers.OnionrUser(signer).addForwardKey(myBlock.getMetadata('newFSKey'))
except onionrexceptions.InvalidPubkey:
logger.warn('%s has invalid forward secrecy key to add: %s' % (signer, myBlock.getMetadata('newFSKey')))
try:
if len(blockType) <= onionrvalues.MAX_BLOCK_TYPE_LENGTH:
blockmetadb.update_block_info(blockHash, 'dataType', blockType)

View File

@ -59,6 +59,7 @@ def on_insertblock(api, data={}):
def on_processblocks(api, data=None):
print('mail got block', data)
if data['type'] != 'pm':
return
data['block'].decrypt()
@ -72,6 +73,8 @@ def on_processblocks(api, data=None):
else:
signer = signer[:5]
print('detected mail', data['block'].hash)
if data['block'].decrypted:
config.reload()
if config.get('mail.notificationSetting', True):
notifier.notification_with_sound(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject']))

View File

@ -19,7 +19,7 @@
"minimum_send_pow": 4,
"public_key": "",
"random_bind_ip": false,
"security_level": 0,
"security_level": 1,
"show_notifications": true,
"socket_servers": false,
"store_plaintext_blocks": true,
@ -72,4 +72,4 @@
"ui": {
"theme": "dark"
}
}
}

View File

@ -1 +1 @@
1582370175
1582445602