mirror of https://gitlab.com/bashrc2/epicyon
Move function
parent
4627933946
commit
1655a68c7c
|
@ -15,7 +15,6 @@ from person import deactivateAccount
|
|||
from skills import setSkillLevel
|
||||
from roles import setRole
|
||||
from webfinger import webfingerHandle
|
||||
#from posts import checkDomains
|
||||
#from posts import getPublicPostDomains
|
||||
#from posts import getPublicPostDomainsBlocked
|
||||
from posts import sendBlockViaServer
|
||||
|
@ -36,6 +35,7 @@ import sys
|
|||
import time
|
||||
from pprint import pprint
|
||||
from daemon import runDaemon
|
||||
from follow import checkDomains
|
||||
from follow import clearFollows
|
||||
from follow import followerOfPerson
|
||||
from follow import sendFollowRequestViaServer
|
||||
|
|
55
follow.py
55
follow.py
|
@ -25,6 +25,61 @@ from auth import createBasicAuthHeader
|
|||
from session import postJson
|
||||
|
||||
|
||||
def checkDomains(session, baseDir: str,
|
||||
nickname: str, domain: str,
|
||||
proxyType: str, port: int, httpPrefix: str,
|
||||
debug: bool, projectVersion: str,
|
||||
maxBlockedDomains: int, singleCheck: bool):
|
||||
"""Checks follower accounts for references to globally blocked domains
|
||||
"""
|
||||
nonMutuals = getNonMutualsOfPerson(baseDir, nickname, domain)
|
||||
if not nonMutuals:
|
||||
return
|
||||
followerWarningFilename = baseDir + '/accounts/followerWarnings.txt'
|
||||
updateFollowerWarnings = False
|
||||
followerWarningStr = ''
|
||||
if os.path.isfile(followerWarningFilename):
|
||||
with open(followerWarningFilename, 'r') as fp:
|
||||
followerWarningStr = fp.read()
|
||||
|
||||
if singleCheck:
|
||||
# checks a single random non-mutual
|
||||
index = random.randrange(0, len(nonMutuals))
|
||||
domainName = nonMutuals[index]
|
||||
blockedDomains = \
|
||||
getPublicPostDomainsBlocked(session, baseDir,
|
||||
nickname, domain,
|
||||
proxyType, port, httpPrefix,
|
||||
debug, projectVersion, [])
|
||||
if blockedDomains:
|
||||
if len(blockedDomains) > maxBlockedDomains:
|
||||
followerWarningStr += domainName + '\n'
|
||||
updateFollowerWarnings = True
|
||||
else:
|
||||
# checks all non-mutuals
|
||||
for domainName in nonMutuals:
|
||||
if domainName in followerWarningStr:
|
||||
continue
|
||||
blockedDomains = \
|
||||
getPublicPostDomainsBlocked(session, baseDir,
|
||||
nickname, domain,
|
||||
proxyType, port, httpPrefix,
|
||||
debug, projectVersion, [])
|
||||
if blockedDomains:
|
||||
print(domainName)
|
||||
for d in blockedDomains:
|
||||
print(' ' + d)
|
||||
if len(blockedDomains) > maxBlockedDomains:
|
||||
followerWarningStr += domainName + '\n'
|
||||
updateFollowerWarnings = True
|
||||
|
||||
if updateFollowerWarnings and followerWarningStr:
|
||||
with open(followerWarningFilename, 'w+') as fp:
|
||||
fp.write(followerWarningStr)
|
||||
if not singleCheck:
|
||||
print(followerWarningStr)
|
||||
|
||||
|
||||
def preApprovedFollower(baseDir: str,
|
||||
nickname: str, domain: str,
|
||||
approveHandle: str) -> bool:
|
||||
|
|
56
posts.py
56
posts.py
|
@ -60,7 +60,6 @@ from filters import isFiltered
|
|||
from git import convertPostToPatch
|
||||
from jsonldsig import jsonldSign
|
||||
from petnames import resolvePetnames
|
||||
from follow import getNonMutualsOfPerson
|
||||
# try:
|
||||
# from BeautifulSoup import BeautifulSoup
|
||||
# except ImportError:
|
||||
|
@ -3332,61 +3331,6 @@ def getPublicPostDomainsBlocked(session, baseDir: str,
|
|||
return blockedDomains
|
||||
|
||||
|
||||
def checkDomains(session, baseDir: str,
|
||||
nickname: str, domain: str,
|
||||
proxyType: str, port: int, httpPrefix: str,
|
||||
debug: bool, projectVersion: str,
|
||||
maxBlockedDomains: int, singleCheck: bool):
|
||||
"""Checks follower accounts for references to globally blocked domains
|
||||
"""
|
||||
nonMutuals = getNonMutualsOfPerson(baseDir, nickname, domain)
|
||||
if not nonMutuals:
|
||||
return
|
||||
followerWarningFilename = baseDir + '/accounts/followerWarnings.txt'
|
||||
updateFollowerWarnings = False
|
||||
followerWarningStr = ''
|
||||
if os.path.isfile(followerWarningFilename):
|
||||
with open(followerWarningFilename, 'r') as fp:
|
||||
followerWarningStr = fp.read()
|
||||
|
||||
if singleCheck:
|
||||
# checks a single random non-mutual
|
||||
index = random.randrange(0, len(nonMutuals))
|
||||
domainName = nonMutuals[index]
|
||||
blockedDomains = \
|
||||
getPublicPostDomainsBlocked(session, baseDir,
|
||||
nickname, domain,
|
||||
proxyType, port, httpPrefix,
|
||||
debug, projectVersion, [])
|
||||
if blockedDomains:
|
||||
if len(blockedDomains) > maxBlockedDomains:
|
||||
followerWarningStr += domainName + '\n'
|
||||
updateFollowerWarnings = True
|
||||
else:
|
||||
# checks all non-mutuals
|
||||
for domainName in nonMutuals:
|
||||
if domainName in followerWarningStr:
|
||||
continue
|
||||
blockedDomains = \
|
||||
getPublicPostDomainsBlocked(session, baseDir,
|
||||
nickname, domain,
|
||||
proxyType, port, httpPrefix,
|
||||
debug, projectVersion, [])
|
||||
if blockedDomains:
|
||||
print(domainName)
|
||||
for d in blockedDomains:
|
||||
print(' ' + d)
|
||||
if len(blockedDomains) > maxBlockedDomains:
|
||||
followerWarningStr += domainName + '\n'
|
||||
updateFollowerWarnings = True
|
||||
|
||||
if updateFollowerWarnings and followerWarningStr:
|
||||
with open(followerWarningFilename, 'w+') as fp:
|
||||
fp.write(followerWarningStr)
|
||||
if not singleCheck:
|
||||
print(followerWarningStr)
|
||||
|
||||
|
||||
def sendCapabilitiesUpdate(session, baseDir: str, httpPrefix: str,
|
||||
nickname: str, domain: str, port: int,
|
||||
followerUrl, updateCaps: [],
|
||||
|
|
Loading…
Reference in New Issue