mirror of https://gitlab.com/bashrc2/epicyon
Accept or deny follow commands for desktop client
parent
26d25c5067
commit
ffb47522c1
|
@ -476,6 +476,8 @@ open [post number] Open web links within a timeline post
|
|||
profile [post number] Show profile for the person who made the given post
|
||||
following [page number] Show accounts that you are following
|
||||
followers [page number] Show accounts that are following you
|
||||
approve [handle] Approve a follow request
|
||||
deny [handle] Deny a follow request
|
||||
```
|
||||
|
||||
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 desktop client will try to obtain the relevant public key and decrypt.
|
||||
|
|
|
@ -29,6 +29,8 @@ from speaker import getSpeakerRate
|
|||
from speaker import getSpeakerRange
|
||||
from like import sendLikeViaServer
|
||||
from like import sendUndoLikeViaServer
|
||||
from follow import approveFollowRequestViaServer
|
||||
from follow import denyFollowRequestViaServer
|
||||
from follow import getFollowRequestsViaServer
|
||||
from follow import getFollowingViaServer
|
||||
from follow import getFollowersViaServer
|
||||
|
@ -117,6 +119,10 @@ def _desktopHelp() -> None:
|
|||
'Show accounts that you are following')
|
||||
print(indent + 'followers [page number] ' +
|
||||
'Show accounts that are following you')
|
||||
print(indent + 'approve [handle] ' +
|
||||
'Approve a follow request')
|
||||
print(indent + 'deny [handle] ' +
|
||||
'Deny a follow request')
|
||||
print('')
|
||||
|
||||
|
||||
|
@ -1544,7 +1550,7 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
|
|||
espeak, translate, yourActor)
|
||||
print('')
|
||||
print(_highlightText('Press Enter to continue...'))
|
||||
enterKey = input()
|
||||
input()
|
||||
prevTimelineFirstId = ''
|
||||
refreshTimeline = True
|
||||
print('')
|
||||
|
@ -2106,6 +2112,70 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
|
|||
_sayCommand(sayStr, sayStr,
|
||||
screenreader, systemLanguage, espeak)
|
||||
print('')
|
||||
elif commandStr.startswith('approve '):
|
||||
approveHandle = commandStr.replace('approve ', '').strip()
|
||||
if approveHandle.startswith('@'):
|
||||
approveHandle = approveHandle[1:]
|
||||
|
||||
if '@' in approveHandle or '://' in approveHandle:
|
||||
approveNickname = getNicknameFromActor(approveHandle)
|
||||
approveDomain, approvePort = \
|
||||
getDomainFromActor(approveHandle)
|
||||
if approveNickname and approveDomain:
|
||||
sayStr = 'Sending approve follow request for ' + \
|
||||
approveNickname + '@' + approveDomain
|
||||
_sayCommand(sayStr, sayStr,
|
||||
screenreader, systemLanguage, espeak)
|
||||
sessionApprove = createSession(proxyType)
|
||||
approveFollowRequestViaServer(baseDir, sessionApprove,
|
||||
nickname, password,
|
||||
domain, port,
|
||||
httpPrefix,
|
||||
approveHandle,
|
||||
cachedWebfingers,
|
||||
personCache,
|
||||
debug,
|
||||
__version__)
|
||||
else:
|
||||
if approveHandle:
|
||||
sayStr = approveHandle + ' is not valid'
|
||||
else:
|
||||
sayStr = 'Specify a handle to approve'
|
||||
_sayCommand(sayStr,
|
||||
screenreader, systemLanguage, espeak)
|
||||
print('')
|
||||
elif commandStr.startswith('deny '):
|
||||
denyHandle = commandStr.replace('deny ', '').strip()
|
||||
if denyHandle.startswith('@'):
|
||||
denyHandle = denyHandle[1:]
|
||||
|
||||
if '@' in denyHandle or '://' in denyHandle:
|
||||
denyNickname = getNicknameFromActor(denyHandle)
|
||||
denyDomain, denyPort = \
|
||||
getDomainFromActor(denyHandle)
|
||||
if denyNickname and denyDomain:
|
||||
sayStr = 'Sending deny follow request for ' + \
|
||||
denyNickname + '@' + denyDomain
|
||||
_sayCommand(sayStr, sayStr,
|
||||
screenreader, systemLanguage, espeak)
|
||||
sessionDeny = createSession(proxyType)
|
||||
denyFollowRequestViaServer(baseDir, sessionDeny,
|
||||
nickname, password,
|
||||
domain, port,
|
||||
httpPrefix,
|
||||
denyHandle,
|
||||
cachedWebfingers,
|
||||
personCache,
|
||||
debug,
|
||||
__version__)
|
||||
else:
|
||||
if denyHandle:
|
||||
sayStr = denyHandle + ' is not valid'
|
||||
else:
|
||||
sayStr = 'Specify a handle to deny'
|
||||
_sayCommand(sayStr,
|
||||
screenreader, systemLanguage, espeak)
|
||||
print('')
|
||||
elif (commandStr == 'repeat' or commandStr == 'replay' or
|
||||
commandStr == 'rp' or commandStr == 'again' or
|
||||
commandStr == 'say again'):
|
||||
|
|
80
follow.py
80
follow.py
|
@ -1357,6 +1357,86 @@ def getFollowRequestsViaServer(baseDir: str, session,
|
|||
return followersJson
|
||||
|
||||
|
||||
def approveFollowRequestViaServer(baseDir: str, session,
|
||||
nickname: str, password: str,
|
||||
domain: str, port: int,
|
||||
httpPrefix: str, approveHandle: int,
|
||||
cachedWebfingers: {}, personCache: {},
|
||||
debug: bool, projectVersion: str) -> str:
|
||||
"""Approves a follow request
|
||||
This is not exactly via c2s though. It simulates pressing the Approve
|
||||
button on the web interface
|
||||
"""
|
||||
if not session:
|
||||
print('WARN: No session for approveFollowRequestViaServer')
|
||||
return 6
|
||||
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
|
||||
authHeader = createBasicAuthHeader(nickname, password)
|
||||
|
||||
headers = {
|
||||
'host': domain,
|
||||
'Content-type': 'text/html; charset=utf-8',
|
||||
'Authorization': authHeader
|
||||
}
|
||||
|
||||
url = actor + '/followapprove=' + approveHandle
|
||||
approveHtml = \
|
||||
getJson(session, url, headers, {}, debug,
|
||||
__version__, httpPrefix, domain, 10, True)
|
||||
if not approveHtml:
|
||||
if debug:
|
||||
print('DEBUG: GET approve follow request failed for c2s to ' + url)
|
||||
return 5
|
||||
|
||||
if debug:
|
||||
print('DEBUG: c2s GET approve follow request request success')
|
||||
|
||||
return approveHtml
|
||||
|
||||
|
||||
def denyFollowRequestViaServer(baseDir: str, session,
|
||||
nickname: str, password: str,
|
||||
domain: str, port: int,
|
||||
httpPrefix: str, denyHandle: int,
|
||||
cachedWebfingers: {}, personCache: {},
|
||||
debug: bool, projectVersion: str) -> str:
|
||||
"""Denies a follow request
|
||||
This is not exactly via c2s though. It simulates pressing the Deny
|
||||
button on the web interface
|
||||
"""
|
||||
if not session:
|
||||
print('WARN: No session for denyFollowRequestViaServer')
|
||||
return 6
|
||||
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
|
||||
authHeader = createBasicAuthHeader(nickname, password)
|
||||
|
||||
headers = {
|
||||
'host': domain,
|
||||
'Content-type': 'text/html; charset=utf-8',
|
||||
'Authorization': authHeader
|
||||
}
|
||||
|
||||
url = actor + '/followdeny=' + denyHandle
|
||||
denyHtml = \
|
||||
getJson(session, url, headers, {}, debug,
|
||||
__version__, httpPrefix, domain, 10, True)
|
||||
if not denyHtml:
|
||||
if debug:
|
||||
print('DEBUG: GET deny follow request failed for c2s to ' + url)
|
||||
return 5
|
||||
|
||||
if debug:
|
||||
print('DEBUG: c2s GET deny follow request request success')
|
||||
|
||||
return denyHtml
|
||||
|
||||
|
||||
def getFollowersOfActor(baseDir: str, actor: str, debug: bool) -> {}:
|
||||
"""In a shared inbox if we receive a post we know who it's from
|
||||
and if it's addressed to followers then we need to get a list of those.
|
||||
|
|
Loading…
Reference in New Issue