mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
136949752f
commit
d352b27dd8
12
inbox.py
12
inbox.py
|
@ -1359,14 +1359,12 @@ def receiveAnnounce(recentPostsCache: {},
|
||||||
messageJson['type'])
|
messageJson['type'])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
prefixes = ('https://', 'http://', 'dat://', 'i2p://', 'gnunet://',
|
||||||
|
'hyper://', 'gemini://', 'gopher://')
|
||||||
# is the domain of the announce actor blocked?
|
# is the domain of the announce actor blocked?
|
||||||
objectDomain = \
|
objectDomain = messageJson['object']
|
||||||
messageJson['object'].replace('https://', '')
|
for prefix in prefixes:
|
||||||
objectDomain = objectDomain.replace('http://', '')
|
objectDomain = objectDomain.replace(prefix, '')
|
||||||
objectDomain = objectDomain.replace('i2p://', '')
|
|
||||||
objectDomain = objectDomain.replace('gnunet://', '')
|
|
||||||
objectDomain = objectDomain.replace('dat://', '')
|
|
||||||
objectDomain = objectDomain.replace('hyper://', '')
|
|
||||||
if '/' in objectDomain:
|
if '/' in objectDomain:
|
||||||
objectDomain = objectDomain.split('/')[0]
|
objectDomain = objectDomain.split('/')[0]
|
||||||
if isBlockedDomain(baseDir, objectDomain):
|
if isBlockedDomain(baseDir, objectDomain):
|
||||||
|
|
30
utils.py
30
utils.py
|
@ -228,30 +228,28 @@ def getDomainFromActor(actor: str) -> (str, int):
|
||||||
"""Returns the domain name from an actor url
|
"""Returns the domain name from an actor url
|
||||||
"""
|
"""
|
||||||
port = None
|
port = None
|
||||||
|
prefixes = ('https://', 'http://', 'dat://', 'i2p://', 'gnunet://',
|
||||||
|
'hyper://', 'gemini://', 'gopher://')
|
||||||
if '/profile/' in actor:
|
if '/profile/' in actor:
|
||||||
domain = actor.split('/profile/')[0].replace('https://', '')
|
domain = actor.split('/profile/')[0]
|
||||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
for prefix in prefixes:
|
||||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
domain = domain.replace(prefix, '')
|
||||||
domain = domain.replace('gnunet://', '')
|
|
||||||
else:
|
else:
|
||||||
if '/channel/' in actor:
|
if '/channel/' in actor:
|
||||||
domain = actor.split('/channel/')[0].replace('https://', '')
|
domain = actor.split('/channel/')[0]
|
||||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
for prefix in prefixes:
|
||||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
domain = domain.replace(prefix, '')
|
||||||
domain = domain.replace('gnunet://', '')
|
|
||||||
else:
|
else:
|
||||||
if '/users/' not in actor:
|
if '/users/' not in actor:
|
||||||
domain = actor.replace('https://', '').replace('http://', '')
|
domain = actor
|
||||||
domain = domain.replace('i2p://', '')
|
for prefix in prefixes:
|
||||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
domain = domain.replace(prefix, '')
|
||||||
domain = domain.replace('gnunet://', '')
|
|
||||||
if '/' in actor:
|
if '/' in actor:
|
||||||
domain = domain.split('/')[0]
|
domain = domain.split('/')[0]
|
||||||
else:
|
else:
|
||||||
domain = actor.split('/users/')[0].replace('https://', '')
|
domain = actor.split('/users/')[0]
|
||||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
for prefix in prefixes:
|
||||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
domain = domain.replace(prefix, '')
|
||||||
domain = domain.replace('gnunet://', '')
|
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
portStr = domain.split(':')[1]
|
portStr = domain.split(':')[1]
|
||||||
if not portStr.isdigit():
|
if not portStr.isdigit():
|
||||||
|
|
Loading…
Reference in New Issue