mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon
commit
11a1cd7de9
|
|
@ -27,6 +27,7 @@ from utils import saveJson
|
|||
from utils import isSuspended
|
||||
from utils import containsInvalidChars
|
||||
from utils import removeHtml
|
||||
from utils import isAccountDir
|
||||
from blocking import isBlockedDomain
|
||||
from blocking import isBlockedHashtag
|
||||
from filters import isFiltered
|
||||
|
|
@ -964,9 +965,7 @@ def _addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
|
|||
# go through each account
|
||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||
for handle in dirs:
|
||||
if '@' not in handle:
|
||||
continue
|
||||
if 'inbox@' in handle or 'news@' in handle:
|
||||
if not isAccountDir(handle):
|
||||
continue
|
||||
|
||||
nickname = handle.split('@')[0]
|
||||
|
|
|
|||
|
|
@ -1220,6 +1220,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
|||
nickname = handle.split(userPath)[1]
|
||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||
domain = handle.split(userPath)[0]
|
||||
userPathFound = True
|
||||
break
|
||||
if not userPathFound and '://' in originalHandle:
|
||||
domain = originalHandle.split('://')[1]
|
||||
|
|
@ -1245,6 +1246,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
|||
nickname = handle.split('@')[0]
|
||||
domain = handle.split('@')[1]
|
||||
domain = domain.replace('\n', '').replace('\r', '')
|
||||
|
||||
cachedWebfingers = {}
|
||||
proxyType = None
|
||||
if http or domain.endswith('.onion'):
|
||||
|
|
|
|||
7
roles.py
7
roles.py
|
|
@ -91,7 +91,8 @@ def _addRole(baseDir: str, nickname: str, domain: str,
|
|||
with open(roleFile, 'w+') as f:
|
||||
for roleNickname in lines:
|
||||
roleNickname = roleNickname.strip('\n').strip('\r')
|
||||
if len(roleNickname) > 1:
|
||||
if len(roleNickname) < 2:
|
||||
continue
|
||||
if os.path.isdir(baseDir + '/accounts/' +
|
||||
roleNickname + '@' + domain):
|
||||
f.write(roleNickname + '\n')
|
||||
|
|
@ -126,6 +127,7 @@ def _setActorRole(actorJson: {}, roleName: str) -> bool:
|
|||
if not isinstance(actorJson['hasOccupation'], list):
|
||||
return False
|
||||
|
||||
# occupation category from www.onetonline.org
|
||||
category = None
|
||||
if 'admin' in roleName:
|
||||
category = '15-1299.01'
|
||||
|
|
@ -228,8 +230,7 @@ def setRole(baseDir: str, nickname: str, domain: str,
|
|||
# avoid giant strings
|
||||
if len(role) > 128:
|
||||
return False
|
||||
actorFilename = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '.json'
|
||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
||||
if not os.path.isfile(actorFilename):
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import datetime
|
|||
from utils import hasObjectDict
|
||||
from utils import getStatusNumber
|
||||
from utils import loadJson
|
||||
from utils import isAccountDir
|
||||
from outbox import postMessageToOutbox
|
||||
|
||||
|
||||
|
|
@ -116,8 +117,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
|||
continue
|
||||
|
||||
# move to the outbox
|
||||
outboxPostFilename = \
|
||||
postFilename.replace('/scheduled/', '/outbox/')
|
||||
outboxPostFilename = postFilename.replace('/scheduled/',
|
||||
'/outbox/')
|
||||
os.rename(postFilename, outboxPostFilename)
|
||||
|
||||
print('Scheduled post sent ' + postId)
|
||||
|
|
@ -144,9 +145,7 @@ def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
|
|||
for account in dirs:
|
||||
if '@' not in account:
|
||||
continue
|
||||
if account.startswith('inbox@'):
|
||||
continue
|
||||
if account.startswith('news@'):
|
||||
if not isAccountDir(account):
|
||||
continue
|
||||
# scheduled posts index for this account
|
||||
scheduleIndexFilename = \
|
||||
|
|
|
|||
17
session.py
17
session.py
|
|
@ -10,6 +10,7 @@ __module_group__ = "Core"
|
|||
import os
|
||||
import requests
|
||||
from utils import urlPermitted
|
||||
from utils import isImageFile
|
||||
import json
|
||||
from socket import error as SocketError
|
||||
import errno
|
||||
|
|
@ -257,12 +258,8 @@ def postImage(session, attachImageFilename: str, federationList: [],
|
|||
print('postJson: ' + inboxUrl + ' not permitted')
|
||||
return None
|
||||
|
||||
if not (attachImageFilename.endswith('.jpg') or
|
||||
attachImageFilename.endswith('.jpeg') or
|
||||
attachImageFilename.endswith('.png') or
|
||||
attachImageFilename.endswith('.svg') or
|
||||
attachImageFilename.endswith('.gif')):
|
||||
print('Image must be png, jpg, gif or svg')
|
||||
if not isImageFile(attachImageFilename):
|
||||
print('Image must be png, jpg, webp, avif, gif or svg')
|
||||
return None
|
||||
if not os.path.isfile(attachImageFilename):
|
||||
print('Image not found: ' + attachImageFilename)
|
||||
|
|
@ -270,9 +267,13 @@ def postImage(session, attachImageFilename: str, federationList: [],
|
|||
contentType = 'image/jpeg'
|
||||
if attachImageFilename.endswith('.png'):
|
||||
contentType = 'image/png'
|
||||
if attachImageFilename.endswith('.gif'):
|
||||
elif attachImageFilename.endswith('.gif'):
|
||||
contentType = 'image/gif'
|
||||
if attachImageFilename.endswith('.svg'):
|
||||
elif attachImageFilename.endswith('.webp'):
|
||||
contentType = 'image/webp'
|
||||
elif attachImageFilename.endswith('.avif'):
|
||||
contentType = 'image/avif'
|
||||
elif attachImageFilename.endswith('.svg'):
|
||||
contentType = 'image/svg+xml'
|
||||
headers['Content-type'] = contentType
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from utils import saveJson
|
|||
from utils import getImageExtensions
|
||||
from utils import hasObjectDict
|
||||
from utils import removeDomainPort
|
||||
from utils import isAccountDir
|
||||
from media import processMetaData
|
||||
|
||||
|
||||
|
|
@ -136,7 +137,8 @@ def addShare(baseDir: str,
|
|||
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
|
||||
formats = getImageExtensions()
|
||||
for ext in formats:
|
||||
if imageFilename.endswith('.' + ext):
|
||||
if not imageFilename.endswith('.' + ext):
|
||||
continue
|
||||
processMetaData(baseDir, nickname, domain,
|
||||
imageFilename, itemIDfile + '.' + ext,
|
||||
city)
|
||||
|
|
@ -162,7 +164,7 @@ def addShare(baseDir: str,
|
|||
# indicate that a new share is available
|
||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||
for handle in dirs:
|
||||
if '@' not in handle:
|
||||
if not isAccountDir(handle):
|
||||
continue
|
||||
accountDir = baseDir + '/accounts/' + handle
|
||||
newShareFile = accountDir + '/.newShare'
|
||||
|
|
@ -182,7 +184,7 @@ def expireShares(baseDir: str) -> None:
|
|||
"""
|
||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||
for account in dirs:
|
||||
if '@' not in account:
|
||||
if not isAccountDir(account):
|
||||
continue
|
||||
nickname = account.split('@')[0]
|
||||
domain = account.split('@')[1]
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ def setActorSkillLevel(actorJson: {},
|
|||
if not actorJson:
|
||||
return True
|
||||
if not actorJson.get('hasOccupation'):
|
||||
actorJson['hasOccupation'] = [
|
||||
{
|
||||
actorJson['hasOccupation'] = [{
|
||||
'@type': 'Occupation',
|
||||
'name': '',
|
||||
"occupationLocation": {
|
||||
|
|
@ -92,8 +91,7 @@ def setActorSkillLevel(actorJson: {},
|
|||
"name": "Fediverse"
|
||||
},
|
||||
'skills': []
|
||||
}
|
||||
]
|
||||
}]
|
||||
ocSkillsList = getOccupationSkills(actorJson)
|
||||
skillsDict = getSkillsFromList(ocSkillsList)
|
||||
if not skillsDict.get(skill):
|
||||
|
|
|
|||
Loading…
Reference in New Issue