work on mail plugin inbox

This commit is contained in:
Kevin Froman 2018-07-17 02:18:17 -05:00
parent f432d9193e
commit 7390945ebf
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 22 additions and 10 deletions

View File

@ -718,7 +718,7 @@ class Core:
# sign before encrypt, as unauthenticated crypto should not be a problem here
if sign:
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)
signer = self._crypto.pubKeyHashID()
signer = self._crypto.pubKey
if len(jsonMeta) > 1000:
raise onionrexceptions.InvalidMetadata('meta in json encoded form must not exceed 1000 bytes')

View File

@ -42,8 +42,6 @@ class Block:
# initialize variables
self.valid = True
self.raw = None
self.powHash = None
self.powToken = None
self.signed = False
self.signature = None
self.signedData = None
@ -69,6 +67,14 @@ class Block:
# logic
def decrypt(self, anonymous=True, encodedData=True):
'''Decrypt a block, loading decrypted data into their vars'''
# decrypt data
self.getCore()._crypto.pubKeyDecrypt(self.bcontent, anonymous=anonymous, encodedData=encodedData)
return
def update(self, data = None, file = None):
'''
Loads data from a block in to the current object.
@ -126,8 +132,6 @@ class Block:
self.bmetadata = json.loads(self.getHeader('meta', None))
self.parent = self.getMetadata('parent', None)
self.btype = self.getMetadata('type', None)
self.powHash = self.getMetadata('powHash', None)
self.powToken = self.getMetadata('powToken', None)
self.signed = ('sig' in self.getHeader() and self.getHeader('sig') != '')
self.signature = self.getHeader('sig', None)
self.signedData = (None if not self.isSigned() else self.getHeader('meta') + '\n' + self.getContent())

View File

@ -49,9 +49,15 @@ class OnionrMail:
return
def inbox(self):
print('PM Blocks:')
blockCount = 0
pmBlockMap = {}
print('Private Messages:')
for blockHash in self.myCore.getBlocksByType('pm'):
print(blockHash)
blockCount += 1
pmBlockMap[blockCount] = blockHash
print('%s: %s' % (blockCount, blockHash))
return
@ -88,10 +94,10 @@ class OnionrMail:
continue
newLine += '\n'
message += newLine
print('Inserting encrypted message as Onionr block....')
self.myCore.insertBlock(message, header='pm', encryptType='asym', asymPeer=recip)
self.myCore.insertBlock(message, header='pm', encryptType='asym', asymPeer=recip, sign=True)
def menu(self):
choice = ''
@ -100,7 +106,7 @@ class OnionrMail:
print(self.strings.programTag + self.strings.mainMenu.title()) # print out main menu
try:
choice = logger.readline('Enter 1-%s:\n' % (len(self.strings.mainMenuChoices))).lower()
choice = logger.readline('Enter 1-%s:\n' % (len(self.strings.mainMenuChoices))).lower().strip()
except (KeyboardInterrupt, EOFError):
choice = '5'
@ -111,6 +117,8 @@ class OnionrMail:
elif choice in (self.strings.mainMenuChoices[4], '5'):
logger.info('Goodbye.')
break
elif choice == '':
pass
else:
logger.warn('Invalid choice.')
return