Don't notify about new shared items from accounts which you have blocked

main
Bob Mottram 2021-08-09 12:00:23 +01:00
parent 23e62dbeb4
commit 42762ef6bd
1 changed files with 11 additions and 3 deletions

View File

@ -40,6 +40,7 @@ from media import processMetaData
from filters import isFilteredGlobally from filters import isFilteredGlobally
from siteactive import siteIsActive from siteactive import siteIsActive
from content import getPriceFromString from content import getPriceFromString
from blocking import isBlocked
def _loadDfcIds(baseDir: str, systemLanguage: str, def _loadDfcIds(baseDir: str, systemLanguage: str,
@ -245,6 +246,7 @@ def _getshareTypeFromDfcId(dfcUri: str, dfcIds: {}) -> str:
def _indicateNewShareAvailable(baseDir: str, httpPrefix: str, def _indicateNewShareAvailable(baseDir: str, httpPrefix: str,
nickname: str, domain: str,
domainFull: str) -> None: domainFull: str) -> None:
"""Indicate to each account that a new share is available """Indicate to each account that a new share is available
""" """
@ -256,11 +258,16 @@ def _indicateNewShareAvailable(baseDir: str, httpPrefix: str,
newShareFile = accountDir + '/.newShare' newShareFile = accountDir + '/.newShare'
if os.path.isfile(newShareFile): if os.path.isfile(newShareFile):
continue continue
nickname = handle.split('@')[0] accountNickname = handle.split('@')[0]
# does this account block you?
if accountNickname != nickname:
if isBlocked(baseDir, accountNickname, domain,
nickname, domain, None):
continue
try: try:
with open(newShareFile, 'w+') as fp: with open(newShareFile, 'w+') as fp:
fp.write(httpPrefix + '://' + domainFull + fp.write(httpPrefix + '://' + domainFull +
'/users/' + nickname + '/tlshares') '/users/' + accountNickname + '/tlshares')
except BaseException: except BaseException:
pass pass
break break
@ -347,7 +354,8 @@ def addShare(baseDir: str,
saveJson(sharesJson, sharesFilename) saveJson(sharesJson, sharesFilename)
_indicateNewShareAvailable(baseDir, httpPrefix, domainFull) _indicateNewShareAvailable(baseDir, httpPrefix,
nickname, domain, domainFull)
def expireShares(baseDir: str) -> None: def expireShares(baseDir: str) -> None: