undo commands

merge-requests/30/head
Bob Mottram 2021-03-20 14:46:24 +00:00
parent 2f4aa7bb3e
commit c41e29c699
1 changed files with 40 additions and 31 deletions

View File

@ -1184,6 +1184,46 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
cachedWebfingers, personCache,
False, __version__)
print('')
elif (commandStr == 'undo bookmark' or
commandStr == 'remove bookmark' or
commandStr == 'rm bookmark' or
commandStr == 'undo bm' or
commandStr == 'rm bm' or
commandStr == 'remove bm' or
commandStr == 'unbookmark' or
commandStr == 'bookmark undo' or
commandStr == 'bm undo ' or
commandStr.startswith('undo bm ') or
commandStr.startswith('remove bm ') or
commandStr.startswith('undo bookmark ') or
commandStr.startswith('remove bookmark ') or
commandStr.startswith('unbookmark ') or
commandStr.startswith('unbm ')):
currIndex = 0
if ' ' in commandStr:
postIndex = commandStr.split(' ')[-1].strip()
if postIndex.isdigit():
currIndex = int(postIndex)
if currIndex > 0 and boxJson:
postJsonObject = \
_desktopGetBoxPostObject(boxJson, currIndex)
if postJsonObject:
if postJsonObject.get('id'):
likeActor = postJsonObject['object']['attributedTo']
sayStr = 'Unbookmarking post by ' + \
getNicknameFromActor(likeActor)
_sayCommand(sayStr, sayStr,
screenreader,
systemLanguage, espeak)
sessionLike = createSession(proxyType)
sendUndoBookmarkViaServer(baseDir, sessionLike,
nickname, password,
domain, port, httpPrefix,
postJsonObject['id'],
cachedWebfingers,
personCache,
False, __version__)
print('')
elif (commandStr == 'bookmark' or
commandStr == 'bm' or
commandStr.startswith('bookmark ') or
@ -1212,37 +1252,6 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
cachedWebfingers, personCache,
False, __version__)
print('')
elif (commandStr == 'undo bookmark' or
commandStr == 'undo bm' or
commandStr == 'unbookmark' or
commandStr == 'unbm' or
commandStr.startswith('unbookmark ') or
commandStr.startswith('unbm ')):
currIndex = 0
if ' ' in commandStr:
postIndex = commandStr.split(' ')[-1].strip()
if postIndex.isdigit():
currIndex = int(postIndex)
if currIndex > 0 and boxJson:
postJsonObject = \
_desktopGetBoxPostObject(boxJson, currIndex)
if postJsonObject:
if postJsonObject.get('id'):
likeActor = postJsonObject['object']['attributedTo']
sayStr = 'Unbookmarking post by ' + \
getNicknameFromActor(likeActor)
_sayCommand(sayStr, sayStr,
screenreader,
systemLanguage, espeak)
sessionLike = createSession(proxyType)
sendUndoBookmarkViaServer(baseDir, sessionLike,
nickname, password,
domain, port, httpPrefix,
postJsonObject['id'],
cachedWebfingers,
personCache,
False, __version__)
print('')
elif commandStr == 'unlike' or commandStr == 'undo like':
currIndex = 0
if ' ' in commandStr: