mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
6ec956e312
commit
825fb76066
8
roles.py
8
roles.py
|
@ -11,6 +11,7 @@ from webfinger import webfingerHandle
|
|||
from auth import createBasicAuthHeader
|
||||
from posts import getPersonBox
|
||||
from session import postJson
|
||||
from utils import getFullDomain
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
from utils import loadJson
|
||||
|
@ -259,12 +260,7 @@ def sendRoleViaServer(baseDir: str, session,
|
|||
print('WARN: No session for sendRoleViaServer')
|
||||
return 6
|
||||
|
||||
delegatorDomainFull = delegatorDomain
|
||||
if delegatorPort:
|
||||
if delegatorPort != 80 and delegatorPort != 443:
|
||||
if ':' not in delegatorDomain:
|
||||
delegatorDomainFull = \
|
||||
delegatorDomain + ':' + str(delegatorPort)
|
||||
delegatorDomainFull = getFullDomain(delegatorDomain, delegatorPort)
|
||||
|
||||
toUrl = \
|
||||
httpPrefix + '://' + delegatorDomainFull + '/users/' + nickname
|
||||
|
|
24
shares.py
24
shares.py
|
@ -13,6 +13,7 @@ from auth import createBasicAuthHeader
|
|||
from posts import getPersonBox
|
||||
from session import postJson
|
||||
from session import postImage
|
||||
from utils import getFullDomain
|
||||
from utils import validNickname
|
||||
from utils import loadJson
|
||||
from utils import saveJson
|
||||
|
@ -115,11 +116,7 @@ def addShare(baseDir: str,
|
|||
imageFilename = sharesImageFilename + '.' + ext
|
||||
moveImage = True
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
# copy or move the image for the shared item to its destination
|
||||
if imageFilename:
|
||||
|
@ -247,10 +244,7 @@ def getSharesFeedForPerson(baseDir: str,
|
|||
if not validNickname(domain, nickname):
|
||||
return None
|
||||
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domain = domain + ':' + str(port)
|
||||
domain = getFullDomain(domain, port)
|
||||
|
||||
handleDomain = domain
|
||||
if ':' in handleDomain:
|
||||
|
@ -331,11 +325,7 @@ def sendShareViaServer(baseDir, session,
|
|||
print('WARN: No session for sendShareViaServer')
|
||||
return 6
|
||||
|
||||
fromDomainFull = fromDomain
|
||||
if fromPort:
|
||||
if fromPort != 80 and fromPort != 443:
|
||||
if ':' not in fromDomain:
|
||||
fromDomainFull = fromDomain + ':' + str(fromPort)
|
||||
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||
|
||||
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
|
||||
ccUrl = httpPrefix + '://' + fromDomainFull + \
|
||||
|
@ -439,11 +429,7 @@ def sendUndoShareViaServer(baseDir: str, session,
|
|||
print('WARN: No session for sendUndoShareViaServer')
|
||||
return 6
|
||||
|
||||
fromDomainFull = fromDomain
|
||||
if fromPort:
|
||||
if fromPort != 80 and fromPort != 443:
|
||||
if ':' not in fromDomain:
|
||||
fromDomainFull = fromDomain + ':' + str(fromPort)
|
||||
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||
|
||||
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
|
||||
ccUrl = httpPrefix + '://' + fromDomainFull + \
|
||||
|
|
|
@ -11,6 +11,7 @@ from webfinger import webfingerHandle
|
|||
from auth import createBasicAuthHeader
|
||||
from posts import getPersonBox
|
||||
from session import postJson
|
||||
from utils import getFullDomain
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
from utils import loadJson
|
||||
|
@ -108,11 +109,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
|
|||
print('WARN: No session for sendSkillViaServer')
|
||||
return 6
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
toUrl = actor
|
||||
|
|
7
tests.py
7
tests.py
|
@ -33,6 +33,7 @@ from follow import clearFollows
|
|||
from follow import clearFollowers
|
||||
from follow import sendFollowRequestViaServer
|
||||
from follow import sendUnfollowRequestViaServer
|
||||
from utils import getFullDomain
|
||||
from utils import validNickname
|
||||
from utils import firstParagraphFromString
|
||||
from utils import removeIdEnding
|
||||
|
@ -127,11 +128,7 @@ def testHttpsigBase(withDigest):
|
|||
}
|
||||
messageBodyJsonStr = json.dumps(messageBodyJson)
|
||||
|
||||
headersDomain = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
headersDomain = domain + ':' + str(port)
|
||||
headersDomain = getFullDomain(domain, port)
|
||||
|
||||
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
|
||||
boxpath = '/inbox'
|
||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
|||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from utils import getFullDomain
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
from utils import locatePost
|
||||
|
@ -35,10 +36,7 @@ def htmlConfirmDelete(cssCache: {},
|
|||
actor = messageId.split('/statuses/')[0]
|
||||
nickname = getNicknameFromActor(actor)
|
||||
domain, port = getDomainFromActor(actor)
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
|
@ -103,10 +101,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
|
|||
itemID = getValidSharedItemID(shareName)
|
||||
nickname = getNicknameFromActor(actor)
|
||||
domain, port = getDomainFromActor(actor)
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
sharesFile = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/shares.json'
|
||||
if not os.path.isfile(sharesFile):
|
||||
|
|
|
@ -11,6 +11,7 @@ from shutil import copyfile
|
|||
from petnames import getPetName
|
||||
from person import isPersonSnoozed
|
||||
from posts import isModerator
|
||||
from utils import getFullDomain
|
||||
from utils import isDormant
|
||||
from utils import removeHtml
|
||||
from utils import getDomainFromActor
|
||||
|
@ -45,10 +46,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
"""Show options for a person: view/follow/block/report
|
||||
"""
|
||||
optionsDomain, optionsPort = getDomainFromActor(optionsActor)
|
||||
optionsDomainFull = optionsDomain
|
||||
if optionsPort:
|
||||
if optionsPort != 80 and optionsPort != 443:
|
||||
optionsDomainFull = optionsDomain + ':' + str(optionsPort)
|
||||
optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
|
||||
|
||||
if os.path.isfile(baseDir + '/accounts/options-background-custom.jpg'):
|
||||
if not os.path.isfile(baseDir + '/accounts/options-background.jpg'):
|
||||
|
@ -74,10 +72,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
dormantMonths)
|
||||
|
||||
optionsNickname = getNicknameFromActor(optionsActor)
|
||||
optionsDomainFull = optionsDomain
|
||||
if optionsPort:
|
||||
if optionsPort != 80 and optionsPort != 443:
|
||||
optionsDomainFull = optionsDomain + ':' + str(optionsPort)
|
||||
optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
|
||||
if isBlocked(baseDir, nickname, domain,
|
||||
optionsNickname, optionsDomainFull):
|
||||
blockStr = 'Block'
|
||||
|
|
|
@ -22,6 +22,7 @@ from posts import getPersonBox
|
|||
from posts import isDM
|
||||
from posts import downloadAnnounce
|
||||
from posts import populateRepliesJson
|
||||
from utils import getFullDomain
|
||||
from utils import isEditor
|
||||
from utils import locatePost
|
||||
from utils import loadJson
|
||||
|
@ -1135,11 +1136,7 @@ def individualPostAsHtml(allowDownloads: bool,
|
|||
if messageId:
|
||||
messageIdStr = ';' + messageId
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
pageNumberParam = ''
|
||||
if pageNumber:
|
||||
|
@ -1604,19 +1601,14 @@ def htmlIndividualPost(cssCache: {},
|
|||
if likedBy:
|
||||
likedByNickname = getNicknameFromActor(likedBy)
|
||||
likedByDomain, likedByPort = getDomainFromActor(likedBy)
|
||||
if likedByPort:
|
||||
if likedByPort != 80 and likedByPort != 443:
|
||||
likedByDomain += ':' + str(likedByPort)
|
||||
likedByDomain = getFullDomain(likedByDomain, likedByPort)
|
||||
likedByHandle = likedByNickname + '@' + likedByDomain
|
||||
postStr += \
|
||||
'<p>' + translate['Liked by'] + \
|
||||
' <a href="' + likedBy + '">@' + \
|
||||
likedByHandle + '</a>\n'
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = '/users/' + nickname
|
||||
followStr = ' <form method="POST" ' + \
|
||||
'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n'
|
||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
|||
|
||||
import os
|
||||
from pprint import pprint
|
||||
from utils import getFullDomain
|
||||
from utils import isDormant
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
|
@ -97,11 +98,7 @@ def htmlProfileAfterSearch(cssCache: {},
|
|||
print('DEBUG: No domain found in ' + profileHandle)
|
||||
return None
|
||||
|
||||
searchDomainFull = searchDomain
|
||||
if searchPort:
|
||||
if searchPort != 80 and searchPort != 443:
|
||||
if ':' not in searchDomain:
|
||||
searchDomainFull = searchDomain + ':' + str(searchPort)
|
||||
searchDomainFull = getFullDomain(searchDomain, searchPort)
|
||||
|
||||
profileStr = ''
|
||||
cssFilename = baseDir + '/epicyon-profile.css'
|
||||
|
@ -225,10 +222,7 @@ def htmlProfileAfterSearch(cssCache: {},
|
|||
profileDescriptionShort,
|
||||
avatarUrl, imageUrl)
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
followIsPermitted = True
|
||||
if searchNickname == 'news' and searchDomainFull == domainFull:
|
||||
|
@ -834,11 +828,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
nickname = getNicknameFromActor(path)
|
||||
if not nickname:
|
||||
return ''
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
actorFilename = \
|
||||
baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
||||
|
|
|
@ -10,6 +10,7 @@ import os
|
|||
from shutil import copyfile
|
||||
import urllib.parse
|
||||
from datetime import datetime
|
||||
from utils import getFullDomain
|
||||
from utils import isEditor
|
||||
from utils import loadJson
|
||||
from utils import getDomainFromActor
|
||||
|
@ -544,10 +545,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
|
|||
htmlHeaderWithExternalStyle(cssFilename)
|
||||
|
||||
# add the page title
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
historySearchForm += \
|
||||
'<center><h1><a href="' + actor + '/search">' + \
|
||||
|
@ -823,10 +821,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
|
|||
if not lines:
|
||||
return None
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
maxFeedLength = 10
|
||||
hashtagFeed = \
|
||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
|||
|
||||
import os
|
||||
import time
|
||||
from utils import getFullDomain
|
||||
from utils import isEditor
|
||||
from utils import removeIdEnding
|
||||
from follow import followerApprovalActive
|
||||
|
@ -191,10 +192,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
eventsButton = 'buttonselected'
|
||||
|
||||
# get the full domain, including any port number
|
||||
fullDomain = domain
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
fullDomain = domain + ':' + str(port)
|
||||
fullDomain = getFullDomain(domain, port)
|
||||
|
||||
usersPath = '/users/' + nickname
|
||||
actor = httpPrefix + '://' + fullDomain + usersPath
|
||||
|
@ -399,10 +397,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
tlStr += ' <tbody>\n'
|
||||
tlStr += ' <tr>\n'
|
||||
|
||||
domainFull = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
# left column
|
||||
leftColumnStr = \
|
||||
|
@ -655,10 +650,7 @@ def htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
|
|||
sharesJson, lastPage = \
|
||||
sharesTimelineJson(actor, pageNumber, itemsPerPage,
|
||||
baseDir, maxSharesPerAccount)
|
||||
domainFull = domain
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domainFull = domain + ':' + str(port)
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
timelineStr = ''
|
||||
|
||||
|
|
16
webfinger.py
16
webfinger.py
|
@ -18,6 +18,7 @@ import urllib.parse
|
|||
from session import getJson
|
||||
from cache import storeWebfingerInCache
|
||||
from cache import getWebfingerFromCache
|
||||
from utils import getFullDomain
|
||||
from utils import loadJson
|
||||
from utils import loadJsonOnionify
|
||||
from utils import saveJson
|
||||
|
@ -113,10 +114,7 @@ def storeWebfingerEndpoint(nickname: str, domain: str, port: int,
|
|||
"""Stores webfinger endpoint for a user to a file
|
||||
"""
|
||||
originalDomain = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domain = domain + ':' + str(port)
|
||||
domain = getFullDomain(domain, port)
|
||||
handle = nickname + '@' + domain
|
||||
wfSubdir = '/wfendpoints'
|
||||
if not os.path.isdir(baseDir + wfSubdir):
|
||||
|
@ -135,10 +133,7 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int,
|
|||
"""Creates a webfinger endpoint for a user
|
||||
"""
|
||||
originalDomain = domain
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in domain:
|
||||
domain = domain + ':' + str(port)
|
||||
domain = getFullDomain(domain, port)
|
||||
|
||||
personName = nickname
|
||||
personId = httpPrefix + "://" + domain + "/users/" + personName
|
||||
|
@ -245,10 +240,7 @@ def webfingerLookup(path: str, baseDir: str,
|
|||
if debug:
|
||||
print('DEBUG: WEBFINGER no @ in handle ' + handle)
|
||||
return None
|
||||
if port:
|
||||
if port != 80 and port != 443:
|
||||
if ':' not in handle:
|
||||
handle = handle + ':' + str(port)
|
||||
handle = getFullDomain(handle, port)
|
||||
# convert @domain@domain to inbox@domain
|
||||
if '@' in handle:
|
||||
handleDomain = handle.split('@')[1]
|
||||
|
|
Loading…
Reference in New Issue