work on mail plugin inbox

master
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 # sign before encrypt, as unauthenticated crypto should not be a problem here
if sign: if sign:
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True) 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: if len(jsonMeta) > 1000:
raise onionrexceptions.InvalidMetadata('meta in json encoded form must not exceed 1000 bytes') raise onionrexceptions.InvalidMetadata('meta in json encoded form must not exceed 1000 bytes')

View File

@ -42,8 +42,6 @@ class Block:
# initialize variables # initialize variables
self.valid = True self.valid = True
self.raw = None self.raw = None
self.powHash = None
self.powToken = None
self.signed = False self.signed = False
self.signature = None self.signature = None
self.signedData = None self.signedData = None
@ -69,6 +67,14 @@ class Block:
# logic # 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): def update(self, data = None, file = None):
''' '''
Loads data from a block in to the current object. 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.bmetadata = json.loads(self.getHeader('meta', None))
self.parent = self.getMetadata('parent', None) self.parent = self.getMetadata('parent', None)
self.btype = self.getMetadata('type', 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.signed = ('sig' in self.getHeader() and self.getHeader('sig') != '')
self.signature = self.getHeader('sig', None) self.signature = self.getHeader('sig', None)
self.signedData = (None if not self.isSigned() else self.getHeader('meta') + '\n' + self.getContent()) self.signedData = (None if not self.isSigned() else self.getHeader('meta') + '\n' + self.getContent())

View File

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