mirror of https://gitlab.com/bashrc2/epicyon
Replace /users/ with other possible paths
parent
39caa248f9
commit
4d771166e0
|
@ -23,6 +23,7 @@ from utils import saveJson
|
|||
from utils import undoAnnounceCollectionEntry
|
||||
from utils import updateAnnounceCollection
|
||||
from utils import localActorUrl
|
||||
from utils import replaceUsersWithAt
|
||||
from posts import sendSignedJson
|
||||
from posts import getPersonBox
|
||||
from session import postJson
|
||||
|
@ -307,7 +308,7 @@ def sendUndoAnnounceViaServer(baseDir: str, session,
|
|||
domainFull = getFullDomain(domain, port)
|
||||
|
||||
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
||||
handle = actor.replace('/users/', '/@')
|
||||
handle = replaceUsersWithAt(actor)
|
||||
|
||||
statusNumber, published = getStatusNumber()
|
||||
unAnnounceJson = {
|
||||
|
|
|
@ -227,6 +227,7 @@ from categories import setHashtagCategory
|
|||
from categories import updateHashtagCategories
|
||||
from languages import getActorLanguages
|
||||
from languages import setActorLanguages
|
||||
from utils import replaceUsersWithAt
|
||||
from utils import localActorUrl
|
||||
from utils import isfloat
|
||||
from utils import validPassword
|
||||
|
@ -11558,7 +11559,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
pinnedPostJson)
|
||||
messageJson['id'] = postId + '/activity'
|
||||
messageJson['object']['id'] = postId
|
||||
messageJson['object']['url'] = postId.replace('/users/', '/@')
|
||||
messageJson['object']['url'] = replaceUsersWithAt(postId)
|
||||
messageJson['object']['atomUri'] = postId
|
||||
msg = json.dumps(messageJson,
|
||||
ensure_ascii=False).encode('utf-8')
|
||||
|
|
|
@ -37,6 +37,7 @@ from roles import setRole
|
|||
from roles import setRolesFromList
|
||||
from roles import getActorRolesList
|
||||
from media import processMetaData
|
||||
from utils import replaceUsersWithAt
|
||||
from utils import removeLineEndings
|
||||
from utils import removeDomainPort
|
||||
from utils import getStatusNumber
|
||||
|
@ -702,7 +703,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
|||
# update domain/@nickname in actors cache
|
||||
actorCacheFilename = \
|
||||
baseDir + '/accounts/cache/actors/' + \
|
||||
personJson['id'].replace('/users/', '/@').replace('/', '#') + \
|
||||
replaceUsersWithAt(personJson['id']).replace('/', '#') + \
|
||||
'.json'
|
||||
if os.path.isfile(actorCacheFilename):
|
||||
saveJson(personJson, actorCacheFilename)
|
||||
|
|
3
pgp.py
3
pgp.py
|
@ -16,6 +16,7 @@ from utils import isPGPEncrypted
|
|||
from utils import getFullDomain
|
||||
from utils import getStatusNumber
|
||||
from utils import localActorUrl
|
||||
from utils import replaceUsersWithAt
|
||||
from webfinger import webfingerHandle
|
||||
from posts import getPersonBox
|
||||
from auth import createBasicAuthHeader
|
||||
|
@ -491,7 +492,7 @@ def pgpPublicKeyUpload(baseDir: str, session,
|
|||
print('Actor for ' + handle + ' obtained')
|
||||
|
||||
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
||||
handle = actor.replace('/users/', '/@')
|
||||
handle = replaceUsersWithAt(actor)
|
||||
|
||||
# check that this looks like the correct actor
|
||||
if not actorJson.get('id'):
|
||||
|
|
7
posts.py
7
posts.py
|
@ -32,6 +32,7 @@ from webfinger import webfingerHandle
|
|||
from httpsig import createSignedHeader
|
||||
from siteactive import siteIsActive
|
||||
from languages import understoodPostLanguage
|
||||
from utils import replaceUsersWithAt
|
||||
from utils import hasGroupType
|
||||
from utils import getBaseContentFromPost
|
||||
from utils import removeDomainPort
|
||||
|
@ -1463,7 +1464,7 @@ def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
|||
'tag': [],
|
||||
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'type': 'Note',
|
||||
'url': actor.replace('/users/', '/@') + '/pinned'
|
||||
'url': replaceUsersWithAt(actor) + '/pinned'
|
||||
}
|
||||
return pinnedPostJson
|
||||
|
||||
|
@ -4440,7 +4441,7 @@ def sendMuteViaServer(baseDir: str, session,
|
|||
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||
|
||||
actor = localActorUrl(httpPrefix, fromNickname, fromDomainFull)
|
||||
handle = actor.replace('/users/', '/@')
|
||||
handle = replaceUsersWithAt(actor)
|
||||
|
||||
newMuteJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
|
@ -4516,7 +4517,7 @@ def sendUndoMuteViaServer(baseDir: str, session,
|
|||
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||
|
||||
actor = localActorUrl(httpPrefix, fromNickname, fromDomainFull)
|
||||
handle = actor.replace('/users/', '/@')
|
||||
handle = replaceUsersWithAt(actor)
|
||||
|
||||
undoMuteJson = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
|
|
11
utils.py
11
utils.py
|
@ -2907,3 +2907,14 @@ def getSharesFilesList() -> []:
|
|||
"""Returns the possible shares files
|
||||
"""
|
||||
return ('shares', 'wanted')
|
||||
|
||||
|
||||
def replaceUsersWithAt(actor: str) -> str:
|
||||
""" https://domain/users/nick becomes https://domain/@nick
|
||||
"""
|
||||
uPaths = getUserPaths()
|
||||
for path in uPaths:
|
||||
if path in actor:
|
||||
actor = actor.replace(path, '/@')
|
||||
break
|
||||
return actor
|
||||
|
|
|
@ -22,6 +22,7 @@ from utils import getAltPath
|
|||
from utils import removeDomainPort
|
||||
from utils import acctDir
|
||||
from utils import localActorUrl
|
||||
from utils import replaceUsersWithAt
|
||||
from happening import getTodaysEvents
|
||||
from happening import getCalendarEvents
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
|
@ -175,7 +176,7 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
|
|||
if senderName and eventDescription:
|
||||
# if the sender is also mentioned within the event
|
||||
# description then this is a reminder
|
||||
senderActor2 = senderActor.replace('/users/', '/@')
|
||||
senderActor2 = replaceUsersWithAt(senderActor)
|
||||
if senderActor not in eventDescription and \
|
||||
senderActor2 not in eventDescription:
|
||||
eventDescription = senderName + eventDescription
|
||||
|
|
Loading…
Reference in New Issue