From 90e02e8af8ff18d0e41821ebd0c203b4788e0dd4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 12 Mar 2021 19:13:01 +0000 Subject: [PATCH] Next and previous commands --- README_commandline.md | 3 +++ notifications_client.py | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/README_commandline.md b/README_commandline.md index cfd5eec3b..f7b533a4c 100644 --- a/README_commandline.md +++ b/README_commandline.md @@ -434,6 +434,9 @@ post to [handle] Create a new direct message announce/boost Boost the last post follow [handle] Make a follow request unfollow [handle] Stop following the give handle +show dm|sent|inbox Show a timeline +next Next page in the timeline +prev Previous page in the timeline ``` If you have a GPG key configured on your local system and are sending a direct message to someone who has a PGP key (the exported key, not just the key ID) set as a tag on their profile then it will try to encrypt the message automatically. So under some conditions end-to-end encryption is possible, such that the instance server only sees ciphertext. Conversely, for arriving direct messages if they are PGP encrypted then the notification client will try to obtain the relevant public key and decrypt. diff --git a/notifications_client.py b/notifications_client.py index 70bdac143..cea2938c9 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -303,7 +303,7 @@ def _showLocalBox(boxName: str, startPostIndex=0, noOfPosts=10) -> None: if not speakerJson.get('published'): continue published = speakerJson['published'].replace('T', ' ') - posStr = str(pos) + '.' + posStr = str(pos + 1) + '.' while len(posStr) < 3: posStr += ' ' if speakerJson.get('name'): @@ -515,6 +515,10 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, content = None cachedWebfingers = {} personCache = {} + currDMIndex = 0 + currSentIndex = 0 + currInboxIndex = 0 + currTimeline = '' while (1): session = createSession(proxyType) speakerJson = \ @@ -660,11 +664,40 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, keyPress = _waitForKeypress(2, debug) break elif keyPress.startswith('show dm'): - _showLocalBox('dm', 0, 10) + _showLocalBox('dm', currDMIndex, 10) + currTimeline = 'dm' elif keyPress.startswith('show sen'): - _showLocalBox('sent', 0, 10) + _showLocalBox('sent', currSentIndex, 10) + currTimeline = 'sent' elif keyPress.startswith('show in'): - _showLocalBox('inbox', 0, 10) + _showLocalBox('inbox', currInboxIndex, 10) + currTimeline = 'inbox' + elif keyPress.startwith('next'): + if currTimeline == 'dm': + currDMIndex += 10 + _showLocalBox('dm', currDMIndex, 10) + elif currTimeline == 'sent': + currSentIndex += 10 + _showLocalBox('sent', currSentIndex, 10) + elif currTimeline == 'inbox': + currInboxIndex += 10 + _showLocalBox('inbox', currInboxIndex, 10) + elif keyPress.startswith('prev'): + if currTimeline == 'dm': + currDMIndex -= 10 + if currDMIndex < 0: + currDMIndex = 0 + _showLocalBox('dm', currDMIndex, 10) + elif currTimeline == 'sent': + currSentIndex -= 10 + if currSentIndex < 0: + currSentIndex = 0 + _showLocalBox('sent', currSentIndex, 10) + elif currTimeline == 'inbox': + currInboxIndex -= 10 + if currInboxIndex < 0: + currInboxIndex = 0 + _showLocalBox('inbox', currInboxIndex, 10) elif keyPress == 'reply' or keyPress == 'r': if speakerJson.get('id'): postId = speakerJson['id']