mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
a6cda457b5
commit
a06186b26e
38
posts.py
38
posts.py
|
@ -492,9 +492,9 @@ def _updateWordFrequency(content: str, wordFrequency: {}) -> None:
|
||||||
that they appear
|
that they appear
|
||||||
"""
|
"""
|
||||||
plainText = removeHtml(content)
|
plainText = removeHtml(content)
|
||||||
plainText = plainText.replace('.', ' ')
|
removeChars = ('.', ';', '?')
|
||||||
plainText = plainText.replace(';', ' ')
|
for ch in removeChars:
|
||||||
plainText = plainText.replace('?', ' ')
|
plainText = plainText.replace(ch, ' ')
|
||||||
wordsList = plainText.split(' ')
|
wordsList = plainText.split(' ')
|
||||||
commonWords = (
|
commonWords = (
|
||||||
'that', 'some', 'about', 'then', 'they', 'were',
|
'that', 'some', 'about', 'then', 'they', 'were',
|
||||||
|
@ -1656,7 +1656,8 @@ def getMentionedPeople(baseDir: str, httpPrefix: str,
|
||||||
mentions = []
|
mentions = []
|
||||||
words = content.split(' ')
|
words = content.split(' ')
|
||||||
for wrd in words:
|
for wrd in words:
|
||||||
if wrd.startswith('@'):
|
if not wrd.startswith('@'):
|
||||||
|
continue
|
||||||
handle = wrd[1:]
|
handle = wrd[1:]
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: mentioned handle ' + handle)
|
print('DEBUG: mentioned handle ' + handle)
|
||||||
|
@ -2140,7 +2141,8 @@ def groupFollowersByDomain(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
grouped = {}
|
grouped = {}
|
||||||
with open(followersFilename, "r") as f:
|
with open(followersFilename, "r") as f:
|
||||||
for followerHandle in f:
|
for followerHandle in f:
|
||||||
if '@' in followerHandle:
|
if '@' not in followerHandle:
|
||||||
|
continue
|
||||||
fHandle = \
|
fHandle = \
|
||||||
followerHandle.strip().replace('\n', '').replace('\r', '')
|
followerHandle.strip().replace('\n', '').replace('\r', '')
|
||||||
followerDomain = fHandle.split('@')[1]
|
followerDomain = fHandle.split('@')[1]
|
||||||
|
@ -2174,9 +2176,9 @@ def _addFollowersToPublicPost(postJsonObject: {}) -> None:
|
||||||
return
|
return
|
||||||
if len(postJsonObject['object']['to']) > 1:
|
if len(postJsonObject['object']['to']) > 1:
|
||||||
return
|
return
|
||||||
if len(postJsonObject['object']['to']) == 0:
|
elif len(postJsonObject['object']['to']) == 0:
|
||||||
return
|
return
|
||||||
if not postJsonObject['object']['to'][0].endswith('#Public'):
|
elif not postJsonObject['object']['to'][0].endswith('#Public'):
|
||||||
return
|
return
|
||||||
if postJsonObject['object'].get('cc'):
|
if postJsonObject['object'].get('cc'):
|
||||||
return
|
return
|
||||||
|
@ -2403,6 +2405,20 @@ def addToField(activityType: str, postJsonObject: {},
|
||||||
return postJsonObject, False
|
return postJsonObject, False
|
||||||
|
|
||||||
|
|
||||||
|
def _isProfileUpdate(postJsonObject: {}) -> bool:
|
||||||
|
"""Is the given post a profile update?
|
||||||
|
for actor updates there is no 'to' within the object
|
||||||
|
"""
|
||||||
|
if postJsonObject['object'].get('type') and postJsonObject.get('type'):
|
||||||
|
if (postJsonObject['type'] == 'Update' and
|
||||||
|
(postJsonObject['object']['type'] == 'Person' or
|
||||||
|
postJsonObject['object']['type'] == 'Application' or
|
||||||
|
postJsonObject['object']['type'] == 'Group' or
|
||||||
|
postJsonObject['object']['type'] == 'Service')):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sendToNamedAddresses(session, baseDir: str,
|
def sendToNamedAddresses(session, baseDir: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
onionDomain: str, i2pDomain: str, port: int,
|
onionDomain: str, i2pDomain: str, port: int,
|
||||||
|
@ -2420,13 +2436,7 @@ def sendToNamedAddresses(session, baseDir: str,
|
||||||
return
|
return
|
||||||
isProfileUpdate = False
|
isProfileUpdate = False
|
||||||
if isinstance(postJsonObject['object'], dict):
|
if isinstance(postJsonObject['object'], dict):
|
||||||
# for actor updates there is no 'to' within the object
|
if _isProfileUpdate(postJsonObject):
|
||||||
if postJsonObject['object'].get('type') and postJsonObject.get('type'):
|
|
||||||
if (postJsonObject['type'] == 'Update' and
|
|
||||||
(postJsonObject['object']['type'] == 'Person' or
|
|
||||||
postJsonObject['object']['type'] == 'Application' or
|
|
||||||
postJsonObject['object']['type'] == 'Group' or
|
|
||||||
postJsonObject['object']['type'] == 'Service')):
|
|
||||||
# use the original object, which has a 'to'
|
# use the original object, which has a 'to'
|
||||||
recipientsObject = postJsonObject
|
recipientsObject = postJsonObject
|
||||||
isProfileUpdate = True
|
isProfileUpdate = True
|
||||||
|
|
Loading…
Reference in New Issue