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