From 443ee5e2c696b0f5c4e4551d371a5c1764fa76f4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Mar 2021 10:37:51 +0000 Subject: [PATCH 1/4] Comment --- notifications_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notifications_client.py b/notifications_client.py index 06eb6188d..7c7e5bde0 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -87,6 +87,8 @@ def _speakerEspeak(espeak, pitch: int, rate: int, srange: int, def _speakerPicospeaker(pitch: int, rate: int, systemLanguage: str, sayText: str) -> None: + """TTS using picospeaker + """ speakerLang = 'en-GB' if systemLanguage: if systemLanguage.startswith('fr'): From 451d44bb21f8f865f7d98c6f64129aa0334dcaab Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Mar 2021 10:42:40 +0000 Subject: [PATCH 2/4] Install gnupg if needed --- install-desktop-notifications | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/install-desktop-notifications b/install-desktop-notifications index d3853110b..6593e166d 100755 --- a/install-desktop-notifications +++ b/install-desktop-notifications @@ -8,10 +8,10 @@ fi if [ ! -f /usr/bin/zenity ]; then if [ -f /usr/bin/apt ]; then - sudo apt install zenity + sudo apt -y install zenity fi if [ -f /usr/bin/pacman ]; then - sudo pacman -S zenity + sudo pacman -S --noconfirm zenity fi fi @@ -32,19 +32,28 @@ fi if [ ! -f /usr/bin/git ]; then if [ -f /usr/bin/apt ]; then - sudo apt install git + sudo apt -y install git fi if [ -f /usr/bin/pacman ]; then - sudo pacman -S git + sudo pacman -S --noconfirm git + fi +fi + +if [ ! -f /usr/bin/gpg ]; then + if [ -f /usr/bin/apt ]; then + sudo apt -y install gnupg + fi + if [ -f /usr/bin/pacman ]; then + sudo pacman -S --noconfirm gnupg fi fi if [ ! -f /usr/bin/python3 ]; then if [ -f /usr/bin/apt ]; then - sudo apt install python3 + sudo apt -y install python3 fi if [ -f /usr/bin/pacman ]; then - sudo pacman -S python + sudo pacman -S --noconfirm python fi fi @@ -65,7 +74,7 @@ if [ -f /usr/bin/notify-send ]; then notificationType='notify-send' else if [ -f /usr/bin/zenity ]; then - notificationType='zenity' + notificationType='zenity' fi fi if [[ ! "$notificationType" ]]; then From a83ae4d0719ab16242b2f5bcedfd273ecf8dfac5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Mar 2021 11:04:44 +0000 Subject: [PATCH 3/4] Generate gpg key --- install-desktop-notifications | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install-desktop-notifications b/install-desktop-notifications index 6593e166d..d6664e141 100755 --- a/install-desktop-notifications +++ b/install-desktop-notifications @@ -82,6 +82,11 @@ if [[ ! "$notificationType" ]]; then exit 5 fi +if [ ! -d ${HOME}/.gnupg ]; then + echo 'Generating GPG key' + gpg --quick-generate-key "${HANDLE}" ed25519 cert +fi + { echo '[Unit]'; echo 'Description=Epicyon Desktop Notifications'; echo ''; From 8e290525733a6225e0f6c50a69d51cde7b5aa7cd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 16 Mar 2021 11:56:24 +0000 Subject: [PATCH 4/4] Don't try to decrypt immediately --- notifications_client.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/notifications_client.py b/notifications_client.py index 7c7e5bde0..8e2bfd0c5 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -365,6 +365,15 @@ def _readLocalBoxPost(boxName: str, index: int, sayStr = 'Reading ' + boxName + ' post ' + str(index) + '.' _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + if speakerJson.get('id') and isPGPEncrypted(content): + sayStr = 'Encrypted message. Please enter your passphrase.' + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + content = pgpDecrypt(content, speakerJson['id']) + if isPGPEncrypted(content): + sayStr = 'Message could not be decrypted' + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + return + time.sleep(2) # say the speaker's name @@ -464,7 +473,9 @@ def _showLocalBox(notifyJson: {}, boxName: str, while len(name) < 16: name += ' ' content = speakerJson['content'] - if speakerJson.get('detectedLinks'): + if isPGPEncrypted(content): + content = '🔒' + content + elif speakerJson.get('detectedLinks'): if len(speakerJson['detectedLinks']) > 0: content = '🔗' + content if len(content) > 40: @@ -855,15 +866,13 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, if speakerJson.get('id') and \ isPGPEncrypted(messageStr): encryptedMessage = True - messageStr = pgpDecrypt(messageStr, - speakerJson['id']) content = messageStr if speakerJson.get('content'): if not encryptedMessage: content = speakerJson['content'] else: - content = '🔓 ' + messageStr + content = '🔒 Encrypted message' if showNewPosts: # say the speaker's name @@ -879,12 +888,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, nameStr, gender) # store incoming post - if encryptedMessage: - speakerJson['content'] = content - speakerJson['say'] = messageStr - speakerJson['decrypted'] = True - _storeMessage(speakerJson, 'dm') - elif speakerJson.get('direct'): + if encryptedMessage or speakerJson.get('direct'): speakerJson['decrypted'] = False _storeMessage(speakerJson, 'dm') else: