From b920aac6ab9bfebc700023428a2f97bd690fe9d2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 12 Mar 2021 10:06:24 +0000 Subject: [PATCH] Store decrypted messages --- notifications_client.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/notifications_client.py b/notifications_client.py index a045ed1b1..b27fb0b21 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -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']