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

View File

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

View File

@ -59,6 +59,7 @@ def on_insertblock(api, data={}):
def on_processblocks(api, data=None): def on_processblocks(api, data=None):
print('mail got block', data)
if data['type'] != 'pm': if data['type'] != 'pm':
return return
data['block'].decrypt() data['block'].decrypt()
@ -72,6 +73,8 @@ def on_processblocks(api, data=None):
else: else:
signer = signer[:5] signer = signer[:5]
print('detected mail', data['block'].hash)
if data['block'].decrypted: if data['block'].decrypted:
config.reload()
if config.get('mail.notificationSetting', True): if config.get('mail.notificationSetting', True):
notifier.notification_with_sound(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject'])) 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, "minimum_send_pow": 4,
"public_key": "", "public_key": "",
"random_bind_ip": false, "random_bind_ip": false,
"security_level": 0, "security_level": 1,
"show_notifications": true, "show_notifications": true,
"socket_servers": false, "socket_servers": false,
"store_plaintext_blocks": true, "store_plaintext_blocks": true,
@ -72,4 +72,4 @@
"ui": { "ui": {
"theme": "dark" "theme": "dark"
} }
} }

View File

@ -1 +1 @@
1582370175 1582445602