better user info syncing and show names in mail

This commit is contained in:
Kevin Froman 2018-08-28 20:09:27 -05:00
parent c907558dd1
commit c0c0f838b6
6 changed files with 33 additions and 12 deletions

View file

@ -19,7 +19,7 @@
'''
# Imports some useful libraries
import logger, config, threading, time
import logger, config, threading, time, uuid
from onionrblockapi import Block
plugin_name = 'cliui'
@ -32,7 +32,7 @@ class OnionrCLIUI:
return
def start(self):
name = input("Enter your name")
self.myCore.insertBlock("userInfo", sign=True, header='userInfo', meta={'name': name})
self.myCore.insertBlock("userInfo-" + str(uuid.uuid1()), sign=True, header='userInfo', meta={'name': name})
return
def on_init(api, data = None):

View file

@ -21,7 +21,7 @@
# Imports some useful libraries
import logger, config, threading, time, readline, datetime
from onionrblockapi import Block
import onionrexceptions
import onionrexceptions, onionrusers
import locale
locale.setlocale(locale.LC_ALL, '')
@ -81,8 +81,15 @@ class OnionrMail:
continue
blockCount += 1
pmBlockMap[blockCount] = blockHash
block = Block(blockHash, core=self.myCore)
senderKey = block.getMetadata('signer')
senderDisplay = onionrusers.OnionrUser(self.myCore, senderKey)
if senderDisplay == 'anonymous':
senderDisplay = senderKey
blockDate = pmBlocks[blockHash].getDate().strftime("%m/%d %H:%M")
print('%s. %s: %s' % (blockCount, blockDate, blockHash))
print('%s. %s - %s: %s' % (blockCount, blockDate, senderDisplay, blockHash))
try:
choice = logger.readline('Enter a block number, -r to refresh, or -q to stop: ').strip().lower()