diff --git a/webapp_column_left.py b/webapp_column_left.py index 5e31af0b2..48a8e9635 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -29,7 +29,7 @@ def _linksExist(baseDir: str) -> bool: def _getLeftColumnShares(baseDir: str, - httpPrefix: str, domainFull: str, + httpPrefix: str, domain: str, domainFull: str, nickname: str, maxSharesInLeftColumn: int, translate: {}, @@ -42,7 +42,7 @@ def _getLeftColumnShares(baseDir: str, # shared items is large sharesJson, lastPage = \ sharesTimelineJson(actor, pageNumber, maxSharesInLeftColumn, - baseDir, maxSharesInLeftColumn, + baseDir, domain, nickname, maxSharesInLeftColumn, sharedItemsFederatedDomains) if not sharesJson: return [] @@ -162,7 +162,7 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str, maxSharesInLeftColumn = 3 sharesList = \ _getLeftColumnShares(baseDir, - httpPrefix, domainFull, nickname, + httpPrefix, domain, domainFull, nickname, maxSharesInLeftColumn, translate, sharedItemsFederatedDomains) if linksList and sharesList: diff --git a/webapp_timeline.py b/webapp_timeline.py index 8b49ede20..d6c8790e7 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -921,7 +921,7 @@ def _htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int, """ sharesJson, lastPage = \ sharesTimelineJson(actor, pageNumber, itemsPerPage, - baseDir, maxSharesPerAccount, + baseDir, domain, nickname, maxSharesPerAccount, sharedItemsFederatedDomains) domainFull = getFullDomain(domain, port) actor = httpPrefix + '://' + domainFull + '/users/' + nickname diff --git a/webapp_utils.py b/webapp_utils.py index c46190b90..85ca3104e 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -27,6 +27,7 @@ from content import addHtmlTags from content import replaceEmojiFromTags from person import getPersonAvatarUrl from posts import isModerator +from blocking import isBlocked def getBrokenLinkSubstitute() -> str: @@ -337,7 +338,8 @@ def scheduledPostsExist(baseDir: str, nickname: str, domain: str) -> bool: def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int, - baseDir: str, maxSharesPerAccount: int, + baseDir: str, domain: str, nickname: str, + maxSharesPerAccount: int, sharedItemsFederatedDomains: []) -> ({}, bool): """Get a page on the shared items timeline as json maxSharesPerAccount helps to avoid one person dominating the timeline @@ -355,9 +357,14 @@ def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int, sharesJson = loadJson(sharesFilename) if not sharesJson: continue - nickname = handle.split('@')[0] + accountNickname = handle.split('@')[0] + # Don't include shared items from blocked accounts + if accountNickname != nickname: + if isBlocked(baseDir, nickname, domain, + accountNickname, domain, None): + continue # actor who owns this share - owner = actor.split('/users/')[0] + '/users/' + nickname + owner = actor.split('/users/')[0] + '/users/' + accountNickname ctr = 0 for itemID, item in sharesJson.items(): # assign owner to the item @@ -387,11 +394,15 @@ def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int, ctr = 0 for itemID, item in sharesJson.items(): # assign owner to the item - shareActor = '' - if '--shareditems--' in itemID: - shareActor = itemID.split('--shareditems--')[0] - shareActor = shareActor.replace('___', '://') - shareActor = shareActor.replace('--', '/') + if '--shareditems--' not in itemID: + continue + shareActor = itemID.split('--shareditems--')[0] + shareActor = shareActor.replace('___', '://') + shareActor = shareActor.replace('--', '/') + shareNickname = getNicknameFromActor(shareActor) + if isBlocked(baseDir, nickname, domain, + shareNickname, federatedDomain, None): + continue item['actor'] = shareActor item['shareId'] = itemID allSharesJson[str(item['published'])] = item