Show Leave rather than Unfollow for groups

merge-requests/30/head
Bob Mottram 2021-09-22 10:29:48 +01:00
parent d02adbc8cd
commit bf1255647e
13 changed files with 226 additions and 238 deletions

View File

@ -264,7 +264,7 @@ def sendAnnounceViaServer(baseDir: str, session,
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey, fromPersonId,
sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -349,7 +349,7 @@ def sendUndoAnnounceViaServer(baseDir: str, session,
originDomain = domain
(inboxUrl, pubKeyId, pubKey, fromPersonId,
sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,

View File

@ -123,9 +123,8 @@ def sendAvailabilityViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,

View File

@ -399,8 +399,8 @@ def sendBookmarkViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -489,8 +489,8 @@ def sendUndoBookmarkViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,

View File

@ -75,7 +75,7 @@ def sendDeleteViaServer(baseDir: str, session,
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem, originDomain,
displayName, _) = getPersonBox(signingPrivateKeyPem, originDomain,
baseDir, session, wfRequest, personCache,
projectVersion, httpPrefix, fromNickname,
fromDomain, postToBox, 53036)

View File

@ -1096,7 +1096,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem, originDomain,
displayName, _) = getPersonBox(signingPrivateKeyPem, originDomain,
baseDir, session, wfRequest, personCache,
projectVersion, httpPrefix, fromNickname,
fromDomain, postToBox, 52025)
@ -1188,9 +1188,8 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session,
wfRequest, personCache,

View File

@ -202,8 +202,8 @@ def sendLikeViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -290,8 +290,8 @@ def sendUndoLikeViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,

5
pgp.py
View File

@ -575,9 +575,8 @@ def pgpPublicKeyUpload(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem, originDomain,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem, originDomain,
baseDir, session, wfRequest, personCache,
__version__, httpPrefix, nickname,
domain, postToBox, 35725)

View File

@ -329,7 +329,7 @@ def getPersonBox(signingPrivateKeyPem: str, originDomain: str,
projectVersion: str, httpPrefix: str,
nickname: str, domain: str,
boxName: str = 'inbox',
sourceId=0) -> (str, str, str, str, str, str, str, str):
sourceId=0) -> (str, str, str, str, str, str, str, str, str):
debug = False
profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = {
@ -368,6 +368,11 @@ def getPersonBox(signingPrivateKeyPem: str, originDomain: str,
if not personJson:
return None, None, None, None, None, None, None
isGroup = False
if personJson.get('type'):
if personJson['type'] == 'Group':
isGroup = True
# get the url for the box/collection
boxJson = None
if not personJson.get(boxName):
@ -416,7 +421,7 @@ def getPersonBox(signingPrivateKeyPem: str, originDomain: str,
storePersonInCache(baseDir, personUrl, personJson, personCache, True)
return boxJson, pubKeyId, pubKey, personId, sharedInbox, \
avatarUrl, displayName
avatarUrl, displayName, isGroup
def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool:
@ -2196,9 +2201,8 @@ def sendPost(signingPrivateKeyPem: str, projectVersion: str,
# get the actor inbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey,
toPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, toPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -2343,9 +2347,8 @@ def sendPostViaServer(signingPrivateKeyPem: str, projectVersion: str,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -2553,7 +2556,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
# get the actor inbox/outbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey, toPersonId, sharedInboxUrl, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -3928,9 +3931,8 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
if debug:
print('Getting the outbox for ' + handle)
(personUrl, pubKeyId, pubKey,
personId, shaedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(personUrl, pubKeyId, pubKey, personId, shaedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -3982,9 +3984,8 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
str(wfRequest))
return domainList
(personUrl, pubKeyId, pubKey,
personId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(personUrl, pubKeyId, pubKey, personId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -4079,9 +4080,8 @@ def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
str(wfRequest))
return {}
(personUrl, pubKeyId, pubKey,
personId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(personUrl, pubKeyId, pubKey, personId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -4618,9 +4618,8 @@ def sendBlockViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -4699,9 +4698,8 @@ def sendMuteViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -4785,9 +4783,8 @@ def sendUndoMuteViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,
@ -4875,9 +4872,8 @@ def sendUndoBlockViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox, avatarUrl,
displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest, personCache,
projectVersion, httpPrefix, fromNickname,

View File

@ -618,9 +618,8 @@ def sendShareViaServer(baseDir, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,
@ -723,9 +722,8 @@ def sendUndoShareViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,
@ -840,9 +838,8 @@ def sendWantedViaServer(baseDir, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,
@ -945,9 +942,8 @@ def sendUndoWantedViaServer(baseDir: str, session,
# get the actor inbox for the To handle
originDomain = fromDomain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,

View File

@ -225,9 +225,8 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
# get the actor inbox for the To handle
originDomain = domain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache, projectVersion,

View File

@ -64,9 +64,8 @@ def instancesGraph(baseDir: str, handles: str,
return dotGraphStr + '}\n'
originDomain = None
(personUrl, pubKeyId, pubKey,
personId, shaedInbox,
avatarUrl, displayName) = getPersonBox(signingPrivateKeyPem,
(personUrl, pubKeyId, pubKey, personId, shaedInbox, avatarUrl,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session, wfRequest,
personCache,

View File

@ -1290,9 +1290,8 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
displayName = None
if postActorWf:
originDomain = domain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl2, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl2,
displayName, _) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session,
postActorWf,

View File

@ -2190,9 +2190,8 @@ def _individualFollowAsHtml(signingPrivateKeyPem: str,
signingPrivateKeyPem)
originDomain = domain
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,
avatarUrl2, displayName) = getPersonBox(signingPrivateKeyPem,
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox, avatarUrl2,
displayName, isGroup) = getPersonBox(signingPrivateKeyPem,
originDomain,
baseDir, session,
followUrlWf,
@ -2221,11 +2220,14 @@ def _individualFollowAsHtml(signingPrivateKeyPem: str,
';1;' + avatarUrl + '"><button class="buttonunfollow">' + \
translate['Block'] + '</button></a>\n'
elif b == 'unfollow':
unfollowStr = 'Unfollow'
if isGroup:
unfollowStr = 'Leave'
buttonsStr += \
'<a href="/users/' + actorNickname + \
'?options=' + followUrl + \
';1;' + avatarUrl + '"><button class="buttonunfollow">' + \
translate['Unfollow'] + '</button></a>\n'
translate[unfollowStr] + '</button></a>\n'
resultStr = '<div class="container">\n'
resultStr += \