Snake case

main
Bob Mottram 2021-12-26 12:31:47 +00:00
parent 257f29a815
commit 4215af54e3
4 changed files with 17 additions and 16 deletions

View File

@ -37,7 +37,7 @@ from utils import dmAllowedFromDomain
from utils import isRecentPost
from utils import getConfigParam
from utils import has_users_path
from utils import validPostDate
from utils import valid_post_date
from utils import getFullDomain
from utils import removeIdEnding
from utils import getProtocolPrefixes
@ -2217,7 +2217,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str,
return False
if 'Z' not in message_json['object']['published']:
return False
if not validPostDate(message_json['object']['published'], 90, debug):
if not valid_post_date(message_json['object']['published'], 90, debug):
return False
summary = None

View File

@ -16,7 +16,7 @@ from datetime import datetime
from datetime import timedelta
from datetime import timezone
from collections import OrderedDict
from utils import validPostDate
from utils import valid_post_date
from categories import setHashtagCategory
from utils import dangerousSVG
from utils import getFavFilenameFromUrl
@ -255,7 +255,7 @@ def _validFeedDate(pubDate: str, debug: bool = False) -> bool:
# convert from YY-MM-DD HH:MM:SS+00:00 to
# YY-MM-DDTHH:MM:SSZ
postDate = pubDate.replace(' ', 'T').replace('+00:00', 'Z')
return validPostDate(postDate, 90, debug)
return valid_post_date(postDate, 90, debug)
def parseFeedDate(pubDate: str) -> str:

View File

@ -47,7 +47,7 @@ from utils import removeInvalidChars
from utils import fileLastModified
from utils import isPublicPost
from utils import has_users_path
from utils import validPostDate
from utils import valid_post_date
from utils import getFullDomain
from utils import getFollowersList
from utils import isEvil
@ -4659,7 +4659,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
base_dir, nickname, domain, postId,
recentPostsCache)
return None
if not validPostDate(announcedJson['published'], 90, debug):
if not valid_post_date(announcedJson['published'], 90, debug):
_rejectAnnounce(announceFilename,
base_dir, nickname, domain, postId,
recentPostsCache)

View File

@ -191,27 +191,27 @@ def get_locked_account(actor_json: {}) -> bool:
return False
def has_users_path(pathStr: str) -> bool:
def has_users_path(path_str: str) -> bool:
"""Whether there is a /users/ path (or equivalent) in the given string
"""
usersList = get_user_paths()
for usersStr in usersList:
if usersStr in pathStr:
users_list = get_user_paths()
for users_str in users_list:
if users_str in path_str:
return True
if '://' in pathStr:
domain = pathStr.split('://')[1]
if '://' in path_str:
domain = path_str.split('://')[1]
if '/' in domain:
domain = domain.split('/')[0]
if '://' + domain + '/' not in pathStr:
if '://' + domain + '/' not in path_str:
return False
nickname = pathStr.split('://' + domain + '/')[1]
nickname = path_str.split('://' + domain + '/')[1]
if '/' in nickname or '.' in nickname:
return False
return True
return False
def validPostDate(published: str, maxAgeDays: int, debug: bool) -> bool:
def valid_post_date(published: str, maxAgeDays: int, debug: bool) -> bool:
"""Returns true if the published date is recent and is not in the future
"""
baselineTime = datetime.datetime(1970, 1, 1)
@ -224,7 +224,8 @@ def validPostDate(published: str, maxAgeDays: int, debug: bool) -> bool:
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
except BaseException:
if debug:
print('EX: validPostDate invalid published date ' + str(published))
print('EX: valid_post_date invalid published date ' +
str(published))
return False
daysDiff = postTimeObject - baselineTime