Store decrypted messages

main
Bob Mottram 2021-03-12 10:06:24 +00:00
parent c88bdf1cd9
commit b920aac6ab
1 changed files with 25 additions and 0 deletions

View File

@ -11,7 +11,9 @@ import html
import time
import sys
import select
from pathlib import Path
from random import randint
from utils import saveJson
from utils import getNicknameFromActor
from utils import getDomainFromActor
from utils import getFullDomain
@ -370,6 +372,23 @@ def _notificationNewDM(session, toHandle: str,
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
def _storeMessage(speakerJson: {}) -> None:
"""Stores a message for later reading
"""
if not speakerJson.get('published'):
return
homeDir = str(Path.home())
if not os.path.isdir(homeDir + '/.config'):
os.mkdir(homeDir + '/.config')
if not os.path.isdir(homeDir + '/.config/epicyon'):
os.mkdir(homeDir + '/.config/epicyon')
msgDir = homeDir + '/.config/epicyon/dm'
if not os.path.isdir(msgDir):
os.mkdir(msgDir)
msgFilename = msgDir + '/' + speakerJson['published'] + '.json'
saveJson(speakerJson, msgFilename)
def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
nickname: str, domain: str, port: int,
password: str, screenreader: str,
@ -543,6 +562,12 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage, espeak,
nameStr, gender)
if encryptedMessage:
speakerJson['content'] = content
speakerJson['say'] = messageStr
speakerJson['decrypted'] = True
_storeMessage(speakerJson)
print('')
prevSay = speakerJson['say']