mirror of https://gitlab.com/bashrc2/epicyon
Separate function for extracting domain name
parent
7c0b0fb195
commit
e0aac3c6a3
|
@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
|
|||
__status__ = "Production"
|
||||
__module_group__ = "ActivityPub"
|
||||
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasObjectDict
|
||||
from utils import removeIdEnding
|
||||
from utils import hasUsersPath
|
||||
|
@ -128,8 +129,7 @@ def createAnnounce(session, baseDir: str, federationList: [],
|
|||
if not urlPermitted(objectUrl, federationList):
|
||||
return None
|
||||
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
fullDomain = getFullDomain(domain, port)
|
||||
|
||||
statusNumber, published = getStatusNumber()
|
||||
|
@ -399,8 +399,7 @@ def outboxUndoAnnounce(recentPostsCache: {},
|
|||
print('DEBUG: c2s undo announce request arrived in outbox')
|
||||
|
||||
messageId = removeIdEnding(messageJson['object']['object'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
|
19
blocking.py
19
blocking.py
|
@ -11,6 +11,7 @@ import os
|
|||
import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasObjectDict
|
||||
from utils import isAccountDir
|
||||
from utils import getCachedPostFilename
|
||||
|
@ -58,8 +59,7 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
|||
blockNickname: str, blockDomain: str) -> bool:
|
||||
"""Block the given account
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
blockingFilename = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/blocking.txt'
|
||||
blockHandle = blockNickname + '@' + blockDomain
|
||||
|
@ -111,8 +111,7 @@ def removeBlock(baseDir: str, nickname: str, domain: str,
|
|||
unblockNickname: str, unblockDomain: str) -> bool:
|
||||
"""Unblock the given account
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
unblockingFilename = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/blocking.txt'
|
||||
unblockHandle = unblockNickname + '@' + unblockDomain
|
||||
|
@ -338,8 +337,7 @@ def outboxBlock(baseDir: str, httpPrefix: str,
|
|||
if debug:
|
||||
print('DEBUG: c2s block object has no nickname')
|
||||
return
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -406,8 +404,7 @@ def outboxUndoBlock(baseDir: str, httpPrefix: str,
|
|||
if debug:
|
||||
print('DEBUG: c2s undo block object has no nickname')
|
||||
return
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -605,8 +602,7 @@ def outboxMute(baseDir: str, httpPrefix: str,
|
|||
if debug:
|
||||
print('DEBUG: c2s mute object has no nickname')
|
||||
return
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -663,8 +659,7 @@ def outboxUndoMute(baseDir: str, httpPrefix: str,
|
|||
if debug:
|
||||
print('DEBUG: c2s undo mute object has no nickname')
|
||||
return
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
|
|
@ -11,6 +11,7 @@ import os
|
|||
from pprint import pprint
|
||||
from webfinger import webfingerHandle
|
||||
from auth import createBasicAuthHeader
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasUsersPath
|
||||
from utils import getFullDomain
|
||||
from utils import removeIdEnding
|
||||
|
@ -560,8 +561,7 @@ def outboxBookmark(recentPostsCache: {},
|
|||
print('DEBUG: c2s bookmark Add request arrived in outbox')
|
||||
|
||||
messageUrl = removeIdEnding(messageJson['object']['url'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageUrl)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -625,8 +625,7 @@ def outboxUndoBookmark(recentPostsCache: {},
|
|||
print('DEBUG: c2s unbookmark Remove request arrived in outbox')
|
||||
|
||||
messageUrl = removeIdEnding(messageJson['object']['url'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageUrl)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
|
|
@ -10,6 +10,7 @@ import os
|
|||
import email.parser
|
||||
import urllib.parse
|
||||
from shutil import copyfile
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import isValidLanguage
|
||||
from utils import getImageExtensions
|
||||
from utils import loadJson
|
||||
|
@ -772,8 +773,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
|
|||
replaceEmoji = {}
|
||||
emojiDict = {}
|
||||
originalDomain = domain
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
followingFilename = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/following.txt'
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ __module_group__ = "ActivityPub"
|
|||
|
||||
import os
|
||||
from datetime import datetime
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasUsersPath
|
||||
from utils import getFullDomain
|
||||
from utils import removeIdEnding
|
||||
|
@ -154,8 +155,7 @@ def outboxDelete(baseDir: str, httpPrefix: str,
|
|||
"wasn't created by you (nickname does not match)")
|
||||
return
|
||||
deleteDomain, deletePort = getDomainFromActor(messageId)
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
if deleteDomain != domain:
|
||||
if debug:
|
||||
print("DEBUG: you can't delete a post which " +
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
__filename__ = "domainhandler.py"
|
||||
__author__ = "Bob Mottram"
|
||||
__license__ = "AGPL3+"
|
||||
__version__ = "1.2.0"
|
||||
__maintainer__ = "Bob Mottram"
|
||||
__email__ = "bob@freedombone.net"
|
||||
__status__ = "Production"
|
||||
__module_group__ = "Core"
|
||||
|
||||
|
||||
def removeDomainPort(domain: str) -> str:
|
||||
"""If the domain has a port appended then remove it
|
||||
eg. mydomain.com:80 becomes mydomain.com
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
return domain
|
|
@ -61,6 +61,7 @@ from tests import testUpdateActor
|
|||
from tests import runAllTests
|
||||
from auth import storeBasicCredentials
|
||||
from auth import createPassword
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasUsersPath
|
||||
from utils import getFullDomain
|
||||
from utils import setConfigParam
|
||||
|
@ -1081,7 +1082,7 @@ if args.message:
|
|||
toPort = 443
|
||||
if ':' in toDomain:
|
||||
toPort = toDomain.split(':')[1]
|
||||
toDomain = toDomain.split(':')[0]
|
||||
toDomain = removeDomainPort(toDomain)
|
||||
else:
|
||||
if args.sendto.endswith('followers'):
|
||||
toNickname = None
|
||||
|
|
16
follow.py
16
follow.py
|
@ -9,6 +9,7 @@ __module_group__ = "ActivityPub"
|
|||
|
||||
from pprint import pprint
|
||||
import os
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasObjectDict
|
||||
from utils import hasUsersPath
|
||||
from utils import getFullDomain
|
||||
|
@ -153,8 +154,7 @@ def isFollowingActor(baseDir: str,
|
|||
"""Is the given nickname following the given actor?
|
||||
The actor can also be a handle: nickname@domain
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
handle = nickname + '@' + domain
|
||||
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
||||
return False
|
||||
|
@ -205,8 +205,7 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
|
|||
followerNickname: str, followerDomain: str) -> bool:
|
||||
"""is the given nickname a follower of followerNickname?
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
followersFile = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/followers.txt'
|
||||
if not os.path.isfile(followersFile):
|
||||
|
@ -243,8 +242,7 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
|||
debug: bool = False) -> bool:
|
||||
"""Removes a person to the follow list
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
handle = nickname + '@' + domain
|
||||
handleToUnfollow = followNickname + '@' + followDomain
|
||||
if not os.path.isdir(baseDir + '/accounts'):
|
||||
|
@ -433,8 +431,7 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str,
|
|||
}
|
||||
|
||||
handleDomain = domain
|
||||
if ':' in handleDomain:
|
||||
handleDomain = domain.split(':')[0]
|
||||
handleDomain = removeDomainPort(handleDomain)
|
||||
handle = nickname + '@' + handleDomain
|
||||
filename = baseDir + '/accounts/' + handle + '/' + followFile + '.txt'
|
||||
if not os.path.isfile(filename):
|
||||
|
@ -493,8 +490,7 @@ def _followApprovalRequired(baseDir: str, nicknameToFollow: str,
|
|||
return False
|
||||
|
||||
manuallyApproveFollows = False
|
||||
if ':' in domainToFollow:
|
||||
domainToFollow = domainToFollow.split(':')[0]
|
||||
domainToFollow = removeDomainPort(domainToFollow)
|
||||
actorFilename = baseDir + '/accounts/' + \
|
||||
nicknameToFollow + '@' + domainToFollow + '.json'
|
||||
if os.path.isfile(actorFilename):
|
||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
|||
__module_group__ = "Calendar"
|
||||
|
||||
import os
|
||||
from domainhandler import removeDomainPort
|
||||
|
||||
|
||||
def receivingCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||
|
@ -43,8 +44,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
|||
indicating whether to receive calendar events from that account
|
||||
"""
|
||||
# check that a following file exists
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
followingFilename = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/following.txt'
|
||||
if not os.path.isfile(followingFilename):
|
||||
|
|
29
inbox.py
29
inbox.py
|
@ -13,6 +13,7 @@ import datetime
|
|||
import time
|
||||
import random
|
||||
from linked_data_sig import verifyJsonSignature
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasObjectDict
|
||||
from utils import dmAllowedFromDomain
|
||||
from utils import isRecentPost
|
||||
|
@ -186,8 +187,7 @@ def _inboxStorePostToHtmlCache(recentPostsCache: {}, maxRecentPosts: int,
|
|||
def validInbox(baseDir: str, nickname: str, domain: str) -> bool:
|
||||
"""Checks whether files were correctly saved to the inbox
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
inboxDir = baseDir + '/accounts/' + nickname + '@' + domain + '/inbox'
|
||||
if not os.path.isdir(inboxDir):
|
||||
return True
|
||||
|
@ -209,8 +209,7 @@ def validInboxFilenames(baseDir: str, nickname: str, domain: str,
|
|||
"""Used by unit tests to check that the port number gets appended to
|
||||
domain names within saved post filenames
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
inboxDir = baseDir + '/accounts/' + nickname + '@' + domain + '/inbox'
|
||||
if not os.path.isdir(inboxDir):
|
||||
return True
|
||||
|
@ -358,8 +357,7 @@ def savePostToInboxQueue(baseDir: str, httpPrefix: str,
|
|||
str(len(messageBytes)) + ' bytes')
|
||||
return None
|
||||
originalDomain = domain
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
|
||||
# block at the ealiest stage possible, which means the data
|
||||
# isn't written to file
|
||||
|
@ -536,8 +534,7 @@ def _inboxPostRecipients(baseDir: str, postJsonObject: {},
|
|||
print('WARNING: inbox post has no actor')
|
||||
return recipientsDict, recipientsDictFollowers
|
||||
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
domainBase = domain
|
||||
domain = getFullDomain(domain, port)
|
||||
domainMatch = '/' + domain + '/users/'
|
||||
|
@ -1124,8 +1121,7 @@ def _receiveBookmark(recentPostsCache: {},
|
|||
print('DEBUG: c2s inbox bookmark Add request arrived in outbox')
|
||||
|
||||
messageUrl = removeIdEnding(messageJson['object']['url'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageUrl)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -1200,8 +1196,7 @@ def _receiveUndoBookmark(recentPostsCache: {},
|
|||
'request arrived in outbox')
|
||||
|
||||
messageUrl = removeIdEnding(messageJson['object']['url'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageUrl)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -1975,8 +1970,7 @@ def _sendToGroupMembers(session, baseDir: str, handle: str, port: int,
|
|||
# set subject
|
||||
if not postJsonObject['object'].get('summary'):
|
||||
postJsonObject['object']['summary'] = 'General Discussion'
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
with open(followersFile, 'r') as groupMembers:
|
||||
for memberHandle in groupMembers:
|
||||
if memberHandle != handle:
|
||||
|
@ -1987,7 +1981,7 @@ def _sendToGroupMembers(session, baseDir: str, handle: str, port: int,
|
|||
memberPortStr = memberDomain.split(':')[1]
|
||||
if memberPortStr.isdigit():
|
||||
memberPort = int(memberPortStr)
|
||||
memberDomain = memberDomain.split(':')[0]
|
||||
memberDomain = removeDomainPort(memberDomain)
|
||||
sendSignedJson(postJsonObject, session, baseDir,
|
||||
nickname, domain, port,
|
||||
memberNickname, memberDomain, memberPort, cc,
|
||||
|
@ -2078,8 +2072,7 @@ def _updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
|
|||
return
|
||||
nickname = handle.split('@')[0]
|
||||
domain = handle.split('@')[1]
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
||||
if not os.path.isdir(accountPath):
|
||||
return
|
||||
|
@ -2133,7 +2126,7 @@ def _bounceDM(senderPostId: str, session, httpPrefix: str,
|
|||
senderPortStr = senderDomain.split(':')[1]
|
||||
if senderPortStr.isdigit():
|
||||
senderPort = int(senderPortStr)
|
||||
senderDomain = senderDomain.split(':')[0]
|
||||
senderDomain = removeDomainPort(senderDomain)
|
||||
cc = []
|
||||
|
||||
# create the bounce DM
|
||||
|
|
7
like.py
7
like.py
|
@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
|
|||
__status__ = "Production"
|
||||
__module_group__ = "ActivityPub"
|
||||
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasObjectDict
|
||||
from utils import hasUsersPath
|
||||
from utils import getFullDomain
|
||||
|
@ -327,8 +328,7 @@ def outboxLike(recentPostsCache: {},
|
|||
print('DEBUG: c2s like request arrived in outbox')
|
||||
|
||||
messageId = removeIdEnding(messageJson['object'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
@ -377,8 +377,7 @@ def outboxUndoLike(recentPostsCache: {},
|
|||
print('DEBUG: c2s undo like request arrived in outbox')
|
||||
|
||||
messageId = removeIdEnding(messageJson['object']['object'])
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
postFilename = locatePost(baseDir, nickname, domain, messageId)
|
||||
if not postFilename:
|
||||
if debug:
|
||||
|
|
|
@ -12,6 +12,7 @@ from follow import followedAccountAccepts
|
|||
from follow import followedAccountRejects
|
||||
from follow import removeFromFollowRequests
|
||||
from utils import loadJson
|
||||
from domainhandler import removeDomainPort
|
||||
|
||||
|
||||
def manualDenyFollowRequest(session, baseDir: str,
|
||||
|
@ -50,7 +51,7 @@ def manualDenyFollowRequest(session, baseDir: str,
|
|||
denyPort = port
|
||||
if ':' in denyDomain:
|
||||
denyPort = denyDomain.split(':')[1]
|
||||
denyDomain = denyDomain.split(':')[0]
|
||||
denyDomain = removeDomainPort(denyDomain)
|
||||
followedAccountRejects(session, baseDir, httpPrefix,
|
||||
nickname, domain, port,
|
||||
denyNickname, denyDomain, denyPort,
|
||||
|
@ -159,7 +160,7 @@ def manualApproveFollowRequest(session, baseDir: str,
|
|||
approvePort = port2
|
||||
if ':' in approveDomain:
|
||||
approvePort = approveDomain.split(':')[1]
|
||||
approveDomain = approveDomain.split(':')[0]
|
||||
approveDomain = removeDomainPort(approveDomain)
|
||||
print('Manual follow accept: Sending Accept for ' +
|
||||
handle + ' follow request from ' +
|
||||
approveNickname + '@' + approveDomain)
|
||||
|
|
10
person.py
10
person.py
|
@ -38,6 +38,7 @@ from roles import setRole
|
|||
from roles import setRolesFromList
|
||||
from roles import getActorRolesList
|
||||
from media import processMetaData
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import getStatusNumber
|
||||
from utils import getFullDomain
|
||||
from utils import validNickname
|
||||
|
@ -93,8 +94,7 @@ def setProfileImage(baseDir: str, httpPrefix: str, nickname: str, domain: str,
|
|||
if imageFilename.startswith('~/'):
|
||||
imageFilename = imageFilename.replace('~/', str(Path.home()) + '/')
|
||||
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
fullDomain = getFullDomain(domain, port)
|
||||
|
||||
handle = nickname + '@' + domain
|
||||
|
@ -147,8 +147,7 @@ def setProfileImage(baseDir: str, httpPrefix: str, nickname: str, domain: str,
|
|||
def _accountExists(baseDir: str, nickname: str, domain: str) -> bool:
|
||||
"""Returns true if the given account exists
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
return os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain) or \
|
||||
os.path.isdir(baseDir + '/deactivated/' + nickname + '@' + domain)
|
||||
|
||||
|
@ -720,8 +719,7 @@ def personLookup(domain: str, path: str, baseDir: str) -> {}:
|
|||
return None
|
||||
if not isSharedInbox and not validNickname(domain, nickname):
|
||||
return None
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
handle = nickname + '@' + domain
|
||||
filename = baseDir + '/accounts/' + handle + '.json'
|
||||
if not os.path.isfile(filename):
|
||||
|
|
8
posts.py
8
posts.py
|
@ -32,6 +32,7 @@ from session import postImage
|
|||
from webfinger import webfingerHandle
|
||||
from httpsig import createSignedHeader
|
||||
from siteactive import siteIsActive
|
||||
from domainhandler import removeDomainPort
|
||||
from utils import hasObjectDict
|
||||
from utils import rejectPostId
|
||||
from utils import removeInvalidChars
|
||||
|
@ -683,8 +684,7 @@ def savePostToBox(baseDir: str, httpPrefix: str, postId: str,
|
|||
boxname != 'scheduled':
|
||||
return None
|
||||
originalDomain = domain
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
|
||||
if not postId:
|
||||
statusNumber, published = getStatusNumber()
|
||||
|
@ -1689,7 +1689,7 @@ def getMentionedPeople(baseDir: str, httpPrefix: str,
|
|||
mentionedNickname = handle.split('@')[0]
|
||||
mentionedDomain = handle.split('@')[1].strip('\n').strip('\r')
|
||||
if ':' in mentionedDomain:
|
||||
mentionedDomain = mentionedDomain.split(':')[0]
|
||||
mentionedDomain = removeDomainPort(mentionedDomain)
|
||||
if not validNickname(mentionedDomain, mentionedNickname):
|
||||
continue
|
||||
actor = \
|
||||
|
@ -2666,7 +2666,7 @@ def sendToFollowers(session, baseDir: str,
|
|||
toDomain = followerHandles[index].split('@')[1]
|
||||
if ':' in toDomain:
|
||||
toPort = toDomain.split(':')[1]
|
||||
toDomain = toDomain.split(':')[0]
|
||||
toDomain = removeDomainPort(toDomain)
|
||||
|
||||
cc = ''
|
||||
|
||||
|
|
4
roles.py
4
roles.py
|
@ -10,6 +10,7 @@ import os
|
|||
from utils import loadJson
|
||||
from utils import saveJson
|
||||
from utils import getStatusNumber
|
||||
from domainhandler import removeDomainPort
|
||||
|
||||
|
||||
def _clearRoleStatus(baseDir: str, role: str) -> None:
|
||||
|
@ -75,8 +76,7 @@ def _addRole(baseDir: str, nickname: str, domain: str,
|
|||
"""Adds a role nickname to the file.
|
||||
This is a file containing the nicknames of accounts having this role
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
roleFile = baseDir + '/accounts/' + roleFilename
|
||||
if os.path.isfile(roleFile):
|
||||
# is this nickname already in the file?
|
||||
|
|
|
@ -20,6 +20,7 @@ from utils import loadJson
|
|||
from utils import saveJson
|
||||
from utils import getImageExtensions
|
||||
from utils import hasObjectDict
|
||||
from domainhandler import removeDomainPort
|
||||
from media import processMetaData
|
||||
|
||||
|
||||
|
@ -187,9 +188,7 @@ def expireShares(baseDir: str) -> None:
|
|||
def _expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||
"""Removes expired items from shares for a particular account
|
||||
"""
|
||||
handleDomain = domain
|
||||
if ':' in handleDomain:
|
||||
handleDomain = domain.split(':')[0]
|
||||
handleDomain = removeDomainPort(domain)
|
||||
handle = nickname + '@' + handleDomain
|
||||
sharesFilename = baseDir + '/accounts/' + handle + '/shares.json'
|
||||
if os.path.isfile(sharesFilename):
|
||||
|
@ -250,9 +249,7 @@ def getSharesFeedForPerson(baseDir: str,
|
|||
|
||||
domain = getFullDomain(domain, port)
|
||||
|
||||
handleDomain = domain
|
||||
if ':' in handleDomain:
|
||||
handleDomain = domain.split(':')[0]
|
||||
handleDomain = removeDomainPort(domain)
|
||||
handle = nickname + '@' + handleDomain
|
||||
sharesFilename = baseDir + '/accounts/' + handle + '/shares.json'
|
||||
|
||||
|
|
18
utils.py
18
utils.py
|
@ -15,6 +15,7 @@ import json
|
|||
import idna
|
||||
import locale
|
||||
from pprint import pprint
|
||||
from domainhandler import removeDomainPort
|
||||
from followingCalendar import addPersonToCalendar
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
|
@ -417,8 +418,7 @@ def getFollowersOfPerson(baseDir: str,
|
|||
Used by the shared inbox to know who to send incoming mail to
|
||||
"""
|
||||
followers = []
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
handle = nickname + '@' + domain
|
||||
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
||||
return followers
|
||||
|
@ -645,8 +645,7 @@ def createInboxQueueDir(nickname: str, domain: str, baseDir: str) -> str:
|
|||
def domainPermitted(domain: str, federationList: []):
|
||||
if len(federationList) == 0:
|
||||
return True
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
if domain in federationList:
|
||||
return True
|
||||
return False
|
||||
|
@ -923,7 +922,7 @@ def getDomainFromActor(actor: str) -> (str, int):
|
|||
if not portStr.isdigit():
|
||||
return None, None
|
||||
port = int(portStr)
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
return domain, port
|
||||
|
||||
|
||||
|
@ -932,8 +931,7 @@ def _setDefaultPetName(baseDir: str, nickname: str, domain: str,
|
|||
"""Sets a default petname
|
||||
This helps especially when using onion or i2p address
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domain)
|
||||
userPath = baseDir + '/accounts/' + nickname + '@' + domain
|
||||
petnamesFilename = userPath + '/petnames.txt'
|
||||
|
||||
|
@ -975,7 +973,8 @@ def followPerson(baseDir: str, nickname: str, domain: str,
|
|||
print('DEBUG: follow of domain ' + followDomain)
|
||||
|
||||
if ':' in domain:
|
||||
handle = nickname + '@' + domain.split(':')[0]
|
||||
domainOnly = removeDomainPort(domain)
|
||||
handle = nickname + '@' + domainOnly
|
||||
else:
|
||||
handle = nickname + '@' + domain
|
||||
|
||||
|
@ -984,7 +983,8 @@ def followPerson(baseDir: str, nickname: str, domain: str,
|
|||
return False
|
||||
|
||||
if ':' in followDomain:
|
||||
handleToFollow = followNickname + '@' + followDomain.split(':')[0]
|
||||
followDomainOnly = removeDomainPort(followDomain)
|
||||
handleToFollow = followNickname + '@' + followDomainOnly
|
||||
else:
|
||||
handleToFollow = followNickname + '@' + followDomain
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ from utils import getDomainFromActor
|
|||
from utils import locatePost
|
||||
from utils import loadJson
|
||||
from utils import weekDayOfMonthStart
|
||||
from domainhandler import removeDomainPort
|
||||
from happening import getTodaysEvents
|
||||
from happening import getCalendarEvents
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
|
@ -247,9 +248,7 @@ def htmlCalendar(personCache: {}, cssCache: {}, translate: {},
|
|||
textModeBanner: str, accessKeys: {}) -> str:
|
||||
"""Show the calendar for a person
|
||||
"""
|
||||
domain = domainFull
|
||||
if ':' in domainFull:
|
||||
domain = domainFull.split(':')[0]
|
||||
domain = removeDomainPort(domainFull)
|
||||
|
||||
monthNumber = 0
|
||||
dayNumber = None
|
||||
|
|
|
@ -11,6 +11,7 @@ import os
|
|||
from utils import getConfigParam
|
||||
from utils import getNicknameFromActor
|
||||
from utils import isEditor
|
||||
from domainhandler import removeDomainPort
|
||||
from webapp_utils import sharesTimelineJson
|
||||
from webapp_utils import htmlPostSeparator
|
||||
from webapp_utils import getLeftImageFile
|
||||
|
@ -76,9 +77,7 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str,
|
|||
htmlStr = ''
|
||||
|
||||
separatorStr = htmlPostSeparator(baseDir, 'left')
|
||||
domain = domainFull
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')
|
||||
domain = removeDomainPort(domainFull)
|
||||
|
||||
editImageClass = ''
|
||||
if showHeaderImage:
|
||||
|
@ -298,9 +297,7 @@ def htmlLinksMobile(cssCache: {}, baseDir: str,
|
|||
else:
|
||||
editor = isEditor(baseDir, nickname)
|
||||
|
||||
domain = domainFull
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
domain = removeDomainPort(domainFull)
|
||||
|
||||
instanceTitle = \
|
||||
getConfigParam(baseDir, 'instanceTitle')
|
||||
|
|
|
@ -17,6 +17,7 @@ from utils import votesOnNewswireItem
|
|||
from utils import getNicknameFromActor
|
||||
from utils import isEditor
|
||||
from utils import getConfigParam
|
||||
from domainhandler import removeDomainPort
|
||||
from posts import isModerator
|
||||
from webapp_utils import getRightImageFile
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
|
@ -58,9 +59,7 @@ def getRightColumnContent(baseDir: str, nickname: str, domainFull: str,
|
|||
"""
|
||||
htmlStr = ''
|
||||
|
||||
domain = domainFull
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')
|
||||
domain = removeDomainPort(domainFull)
|
||||
|
||||
if authorized:
|
||||
# only show the publish button if logged in, otherwise replace it with
|
||||
|
|
10
webfinger.py
10
webfinger.py
|
@ -17,6 +17,7 @@ from utils import loadJson
|
|||
from utils import loadJsonOnionify
|
||||
from utils import saveJson
|
||||
from utils import getProtocolPrefixes
|
||||
from domainhandler import removeDomainPort
|
||||
|
||||
|
||||
def _parseHandle(handle: str) -> (str, str):
|
||||
|
@ -53,13 +54,8 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
|
|||
nickname, domain = _parseHandle(handle)
|
||||
if not nickname:
|
||||
return None
|
||||
wfDomain = domain
|
||||
if ':' in wfDomain:
|
||||
# wfPortStr=wfDomain.split(':')[1]
|
||||
# if wfPortStr.isdigit():
|
||||
# wfPort=int(wfPortStr)
|
||||
# if wfPort==80 or wfPort==443:
|
||||
wfDomain = wfDomain.split(':')[0]
|
||||
wfDomain = removeDomainPort(domain)
|
||||
|
||||
wf = getWebfingerFromCache(nickname + '@' + wfDomain,
|
||||
cachedWebfingers)
|
||||
if wf:
|
||||
|
|
Loading…
Reference in New Issue