forked from indymedia/epicyon
Allow accounts as users path
parent
5ab09b996b
commit
58bba56e75
|
@ -202,6 +202,7 @@ def receiveAcceptReject(session, baseDir: str,
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no actor')
|
print('DEBUG: ' + messageJson['type'] + ' has no actor')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -147,6 +147,7 @@ def createAnnounce(session, baseDir: str, federationList: [],
|
||||||
announceDomain = None
|
announceDomain = None
|
||||||
announcePort = None
|
announcePort = None
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
announceNickname = getNicknameFromActor(objectUrl)
|
announceNickname = getNicknameFromActor(objectUrl)
|
||||||
|
@ -263,6 +264,7 @@ def undoAnnounce(session, baseDir: str, federationList: [],
|
||||||
announceDomain = None
|
announceDomain = None
|
||||||
announcePort = None
|
announcePort = None
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
announceNickname = getNicknameFromActor(objectUrl)
|
announceNickname = getNicknameFromActor(objectUrl)
|
||||||
|
|
1
auth.py
1
auth.py
|
@ -57,6 +57,7 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str,
|
||||||
'contain a space character')
|
'contain a space character')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in path and \
|
if '/users/' not in path and \
|
||||||
|
'/accounts/' not in path and \
|
||||||
'/channel/' not in path and \
|
'/channel/' not in path and \
|
||||||
'/profile/' not in path:
|
'/profile/' not in path:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -220,6 +220,7 @@ def outboxBlock(baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: c2s block object is not a status')
|
print('DEBUG: c2s block object is not a status')
|
||||||
return
|
return
|
||||||
if '/users/' not in messageId and \
|
if '/users/' not in messageId and \
|
||||||
|
'/accounts/' not in messageId and \
|
||||||
'/channel/' not in messageId and \
|
'/channel/' not in messageId and \
|
||||||
'/profile/' not in messageId:
|
'/profile/' not in messageId:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -298,6 +299,7 @@ def outboxUndoBlock(baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: c2s undo block object is not a status')
|
print('DEBUG: c2s undo block object is not a status')
|
||||||
return
|
return
|
||||||
if '/users/' not in messageId and \
|
if '/users/' not in messageId and \
|
||||||
|
'/accounts/' not in messageId and \
|
||||||
'/channel/' not in messageId and \
|
'/channel/' not in messageId and \
|
||||||
'/profile/' not in messageId:
|
'/profile/' not in messageId:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -262,6 +262,7 @@ def bookmark(recentPostsCache: {},
|
||||||
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
|
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
|
||||||
else:
|
else:
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
ou = objectUrl
|
ou = objectUrl
|
||||||
|
@ -362,6 +363,7 @@ def undoBookmark(recentPostsCache: {},
|
||||||
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
|
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
|
||||||
else:
|
else:
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
ou = objectUrl
|
ou = objectUrl
|
||||||
|
|
|
@ -5914,7 +5914,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
self._400()
|
self._400()
|
||||||
elif path.startswith('/api/v1/crypto/keys/query'):
|
elif path.startswith('/api/v1/crypto/keys/query'):
|
||||||
# given a handle (nickname@domain) return the devices
|
# given a handle (nickname@domain) return a list of the devices
|
||||||
# registered to that handle
|
# registered to that handle
|
||||||
if not self._cryptoAPIQuery():
|
if not self._cryptoAPIQuery():
|
||||||
self._400()
|
self._400()
|
||||||
|
|
|
@ -67,6 +67,7 @@ def createDelete(session, baseDir: str, federationList: [],
|
||||||
deleteDomain = None
|
deleteDomain = None
|
||||||
deletePort = None
|
deletePort = None
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
deleteNickname = getNicknameFromActor(objectUrl)
|
deleteNickname = getNicknameFromActor(objectUrl)
|
||||||
|
@ -262,6 +263,7 @@ def outboxDelete(baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: c2s delete object is not a status')
|
print('DEBUG: c2s delete object is not a status')
|
||||||
return
|
return
|
||||||
if '/users/' not in messageId and \
|
if '/users/' not in messageId and \
|
||||||
|
'/accounts/' not in messageId and \
|
||||||
'/channel/' not in messageId and \
|
'/channel/' not in messageId and \
|
||||||
'/profile/' not in messageId:
|
'/profile/' not in messageId:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
11
epicyon.py
11
epicyon.py
|
@ -1130,6 +1130,7 @@ if args.actor:
|
||||||
args.actor = args.actor.replace(prefix, '')
|
args.actor = args.actor.replace(prefix, '')
|
||||||
args.actor = args.actor.replace('/@', '/users/')
|
args.actor = args.actor.replace('/@', '/users/')
|
||||||
if '/users/' not in args.actor and \
|
if '/users/' not in args.actor and \
|
||||||
|
'/accounts/' not in args.actor and \
|
||||||
'/channel/' not in args.actor and \
|
'/channel/' not in args.actor and \
|
||||||
'/profile/' not in args.actor:
|
'/profile/' not in args.actor:
|
||||||
print('Expected actor format: ' +
|
print('Expected actor format: ' +
|
||||||
|
@ -1143,10 +1144,14 @@ if args.actor:
|
||||||
nickname = args.actor.split('/profile/')[1]
|
nickname = args.actor.split('/profile/')[1]
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
domain = args.actor.split('/profile/')[0]
|
domain = args.actor.split('/profile/')[0]
|
||||||
else:
|
elif '/channel/' in args.actor:
|
||||||
nickname = args.actor.split('/channel/')[1]
|
nickname = args.actor.split('/channel/')[1]
|
||||||
nickname = nickname.replace('\n', '').replace('\r', '')
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
domain = args.actor.split('/channel/')[0]
|
domain = args.actor.split('/channel/')[0]
|
||||||
|
elif '/accounts/' in args.actor:
|
||||||
|
nickname = args.actor.split('/accounts/')[1]
|
||||||
|
nickname = nickname.replace('\n', '').replace('\r', '')
|
||||||
|
domain = args.actor.split('/accounts/')[0]
|
||||||
else:
|
else:
|
||||||
# format: @nick@domain
|
# format: @nick@domain
|
||||||
if '@' not in args.actor:
|
if '@' not in args.actor:
|
||||||
|
@ -1198,6 +1203,7 @@ if args.actor:
|
||||||
if wfRequest.get('errors'):
|
if wfRequest.get('errors'):
|
||||||
print('wfRequest error: ' + str(wfRequest['errors']))
|
print('wfRequest error: ' + str(wfRequest['errors']))
|
||||||
if '/users/' in args.actor or \
|
if '/users/' in args.actor or \
|
||||||
|
'/accounts/' in args.actor or \
|
||||||
'/profile/' in args.actor or \
|
'/profile/' in args.actor or \
|
||||||
'/channel/' in args.actor:
|
'/channel/' in args.actor:
|
||||||
personUrl = originalActor
|
personUrl = originalActor
|
||||||
|
@ -1212,6 +1218,7 @@ if args.actor:
|
||||||
personUrl = getUserUrl(wfRequest)
|
personUrl = getUserUrl(wfRequest)
|
||||||
if nickname == domain:
|
if nickname == domain:
|
||||||
personUrl = personUrl.replace('/users/', '/actor/')
|
personUrl = personUrl.replace('/users/', '/actor/')
|
||||||
|
personUrl = personUrl.replace('/accounts/', '/actor/')
|
||||||
personUrl = personUrl.replace('/channel/', '/actor/')
|
personUrl = personUrl.replace('/channel/', '/actor/')
|
||||||
personUrl = personUrl.replace('/profile/', '/actor/')
|
personUrl = personUrl.replace('/profile/', '/actor/')
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
|
@ -1221,7 +1228,7 @@ if args.actor:
|
||||||
asHeader = {
|
asHeader = {
|
||||||
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
if '/channel/' in personUrl:
|
if '/channel/' in personUrl or '/accounts/' in personUrl:
|
||||||
profileStr = 'https://www.w3.org/ns/activitystreams'
|
profileStr = 'https://www.w3.org/ns/activitystreams'
|
||||||
asHeader = {
|
asHeader = {
|
||||||
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
||||||
|
|
|
@ -555,6 +555,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: follow request has no actor')
|
print('DEBUG: follow request has no actor')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -582,6 +583,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
if not messageJson.get('to'):
|
if not messageJson.get('to'):
|
||||||
messageJson['to'] = messageJson['object']
|
messageJson['to'] = messageJson['object']
|
||||||
if '/users/' not in messageJson['object'] and \
|
if '/users/' not in messageJson['object'] and \
|
||||||
|
'/accounts/' not in messageJson['object'] and \
|
||||||
'/channel/' not in messageJson['object'] and \
|
'/channel/' not in messageJson['object'] and \
|
||||||
'/profile/' not in messageJson['object']:
|
'/profile/' not in messageJson['object']:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -64,7 +64,7 @@ def saveEvent(baseDir: str, handle: str, postId: str,
|
||||||
if eventMonthNumber < 1 or eventMonthNumber > 12:
|
if eventMonthNumber < 1 or eventMonthNumber > 12:
|
||||||
return False
|
return False
|
||||||
eventDayOfMonth = int(eventTime.strftime("%d"))
|
eventDayOfMonth = int(eventTime.strftime("%d"))
|
||||||
if eventDayOfMonth < 1or eventDayOfMonth > 31:
|
if eventDayOfMonth < 1 or eventDayOfMonth > 31:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if eventJson.get('name') and eventJson.get('actor') and \
|
if eventJson.get('name') and eventJson.get('actor') and \
|
||||||
|
|
23
inbox.py
23
inbox.py
|
@ -661,6 +661,7 @@ def receiveUndoFollow(session, baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: follow request has no actor within object')
|
print('DEBUG: follow request has no actor within object')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['object']['actor'] and \
|
if '/users/' not in messageJson['object']['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['object']['actor'] and \
|
||||||
'/channel/' not in messageJson['object']['actor'] and \
|
'/channel/' not in messageJson['object']['actor'] and \
|
||||||
'/profile/' not in messageJson['object']['actor']:
|
'/profile/' not in messageJson['object']['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -735,6 +736,7 @@ def receiveUndo(session, baseDir: str, httpPrefix: str,
|
||||||
print('DEBUG: follow request has no actor')
|
print('DEBUG: follow request has no actor')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -792,11 +794,13 @@ def personReceiveUpdate(baseDir: str,
|
||||||
if actor not in personJson['id']:
|
if actor not in personJson['id']:
|
||||||
actor = updateDomainFull + '/channel/' + updateNickname
|
actor = updateDomainFull + '/channel/' + updateNickname
|
||||||
if actor not in personJson['id']:
|
if actor not in personJson['id']:
|
||||||
if debug:
|
actor = updateDomainFull + '/accounts/' + updateNickname
|
||||||
print('actor: ' + actor)
|
if actor not in personJson['id']:
|
||||||
print('id: ' + personJson['id'])
|
if debug:
|
||||||
print('DEBUG: Actor does not match id')
|
print('actor: ' + actor)
|
||||||
return False
|
print('id: ' + personJson['id'])
|
||||||
|
print('DEBUG: Actor does not match id')
|
||||||
|
return False
|
||||||
if updateDomainFull == domainFull:
|
if updateDomainFull == domainFull:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: You can only receive actor updates ' +
|
print('DEBUG: You can only receive actor updates ' +
|
||||||
|
@ -907,6 +911,7 @@ def receiveUpdate(recentPostsCache: {}, session, baseDir: str,
|
||||||
print('DEBUG: ' + messageJson['type'] + ' object has no type')
|
print('DEBUG: ' + messageJson['type'] + ' object has no type')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1008,6 +1013,7 @@ def receiveLike(recentPostsCache: {},
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no "to" list')
|
print('DEBUG: ' + messageJson['type'] + ' has no "to" list')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1076,6 +1082,7 @@ def receiveUndoLike(recentPostsCache: {},
|
||||||
' like object is not a string')
|
' like object is not a string')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1288,6 +1295,7 @@ def receiveDelete(session, handle: str, isGroup: bool, baseDir: str,
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no "to" list')
|
print('DEBUG: ' + messageJson['type'] + ' has no "to" list')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1358,6 +1366,7 @@ def receiveAnnounce(recentPostsCache: {},
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no "to" list')
|
print('DEBUG: ' + messageJson['type'] + ' has no "to" list')
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1366,6 +1375,7 @@ def receiveAnnounce(recentPostsCache: {},
|
||||||
messageJson['type'])
|
messageJson['type'])
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['object'] and \
|
if '/users/' not in messageJson['object'] and \
|
||||||
|
'/accounts/' not in messageJson['object'] and \
|
||||||
'/channel/' not in messageJson['object'] and \
|
'/channel/' not in messageJson['object'] and \
|
||||||
'/profile/' not in messageJson['object']:
|
'/profile/' not in messageJson['object']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1434,6 +1444,7 @@ def receiveAnnounce(recentPostsCache: {},
|
||||||
lookupActor = attrib
|
lookupActor = attrib
|
||||||
if lookupActor:
|
if lookupActor:
|
||||||
if '/users/' in lookupActor or \
|
if '/users/' in lookupActor or \
|
||||||
|
'/accounts/' in lookupActor or \
|
||||||
'/channel/' in lookupActor or \
|
'/channel/' in lookupActor or \
|
||||||
'/profile/' in lookupActor:
|
'/profile/' in lookupActor:
|
||||||
if '/statuses/' in lookupActor:
|
if '/statuses/' in lookupActor:
|
||||||
|
@ -1485,6 +1496,7 @@ def receiveUndoAnnounce(recentPostsCache: {},
|
||||||
if messageJson['object']['type'] != 'Announce':
|
if messageJson['object']['type'] != 'Announce':
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor'] and \
|
if '/users/' not in messageJson['actor'] and \
|
||||||
|
'/accounts/' not in messageJson['actor'] and \
|
||||||
'/channel/' not in messageJson['actor'] and \
|
'/channel/' not in messageJson['actor'] and \
|
||||||
'/profile/' not in messageJson['actor']:
|
'/profile/' not in messageJson['actor']:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1679,6 +1691,7 @@ def obtainAvatarForReplyPost(session, baseDir: str, httpPrefix: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
if not ('/users/' in lookupActor or
|
if not ('/users/' in lookupActor or
|
||||||
|
'/accounts/' in lookupActor or
|
||||||
'/channel/' in lookupActor or
|
'/channel/' in lookupActor or
|
||||||
'/profile/' in lookupActor):
|
'/profile/' in lookupActor):
|
||||||
return
|
return
|
||||||
|
|
2
like.py
2
like.py
|
@ -90,6 +90,7 @@ def like(recentPostsCache: {},
|
||||||
likedPostDomain, likedPostPort = getDomainFromActor(actorLiked)
|
likedPostDomain, likedPostPort = getDomainFromActor(actorLiked)
|
||||||
else:
|
else:
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
likedPostNickname = getNicknameFromActor(objectUrl)
|
likedPostNickname = getNicknameFromActor(objectUrl)
|
||||||
|
@ -193,6 +194,7 @@ def undolike(recentPostsCache: {},
|
||||||
likedPostDomain, likedPostPort = getDomainFromActor(actorLiked)
|
likedPostDomain, likedPostPort = getDomainFromActor(actorLiked)
|
||||||
else:
|
else:
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
|
'/accounts/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
likedPostNickname = getNicknameFromActor(objectUrl)
|
likedPostNickname = getNicknameFromActor(objectUrl)
|
||||||
|
|
7
posts.py
7
posts.py
|
@ -136,6 +136,7 @@ def getUserUrl(wfRequest: {}) -> str:
|
||||||
if link.get('type') and link.get('href'):
|
if link.get('type') and link.get('href'):
|
||||||
if link['type'] == 'application/activity+json':
|
if link['type'] == 'application/activity+json':
|
||||||
if not ('/users/' in link['href'] or
|
if not ('/users/' in link['href'] or
|
||||||
|
'/accounts/' in link['href'] or
|
||||||
'/profile/' in link['href'] or
|
'/profile/' in link['href'] or
|
||||||
'/channel/' in link['href']):
|
'/channel/' in link['href']):
|
||||||
print('Webfinger activity+json contains ' +
|
print('Webfinger activity+json contains ' +
|
||||||
|
@ -207,7 +208,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
return None, None, None, None, None, None, None, None
|
return None, None, None, None, None, None, None, None
|
||||||
personJson = getPersonFromCache(baseDir, personUrl, personCache)
|
personJson = getPersonFromCache(baseDir, personUrl, personCache)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
if '/channel/' in personUrl:
|
if '/channel/' in personUrl or '/accounts/' in personUrl:
|
||||||
asHeader = {
|
asHeader = {
|
||||||
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
|
@ -3188,7 +3189,8 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
||||||
asHeader = {
|
asHeader = {
|
||||||
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
if '/channel/' in postJsonObject['actor']:
|
if '/channel/' in postJsonObject['actor'] or \
|
||||||
|
'/accounts/' in postJsonObject['actor']:
|
||||||
asHeader = {
|
asHeader = {
|
||||||
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
'Accept': 'application/ld+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
|
@ -3238,6 +3240,7 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
||||||
rejectAnnounce(announceFilename)
|
rejectAnnounce(announceFilename)
|
||||||
return None
|
return None
|
||||||
if '/users/' not in announcedJson['id'] and \
|
if '/users/' not in announcedJson['id'] and \
|
||||||
|
'/accounts/' not in announcedJson['id'] and \
|
||||||
'/channel/' not in announcedJson['id'] and \
|
'/channel/' not in announcedJson['id'] and \
|
||||||
'/profile/' not in announcedJson['id']:
|
'/profile/' not in announcedJson['id']:
|
||||||
rejectAnnounce(announceFilename)
|
rejectAnnounce(announceFilename)
|
||||||
|
|
44
utils.py
44
utils.py
|
@ -222,14 +222,20 @@ def getNicknameFromActor(actor: str) -> str:
|
||||||
return nickStr
|
return nickStr
|
||||||
else:
|
else:
|
||||||
return nickStr.split('/')[0]
|
return nickStr.split('/')[0]
|
||||||
if '/channel/' in actor:
|
elif '/channel/' in actor:
|
||||||
nickStr = actor.split('/channel/')[1].replace('@', '')
|
nickStr = actor.split('/channel/')[1].replace('@', '')
|
||||||
if '/' not in nickStr:
|
if '/' not in nickStr:
|
||||||
return nickStr
|
return nickStr
|
||||||
else:
|
else:
|
||||||
return nickStr.split('/')[0]
|
return nickStr.split('/')[0]
|
||||||
# https://domain/@nick
|
elif '/accounts/' in actor:
|
||||||
if '/@' in actor:
|
nickStr = actor.split('/accounts/')[1].replace('@', '')
|
||||||
|
if '/' not in nickStr:
|
||||||
|
return nickStr
|
||||||
|
else:
|
||||||
|
return nickStr.split('/')[0]
|
||||||
|
elif '/@' in actor:
|
||||||
|
# https://domain/@nick
|
||||||
nickStr = actor.split('/@')[1]
|
nickStr = actor.split('/@')[1]
|
||||||
if '/' in nickStr:
|
if '/' in nickStr:
|
||||||
nickStr = nickStr.split('/')[0]
|
nickStr = nickStr.split('/')[0]
|
||||||
|
@ -251,22 +257,24 @@ def getDomainFromActor(actor: str) -> (str, int):
|
||||||
domain = actor.split('/profile/')[0]
|
domain = actor.split('/profile/')[0]
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
domain = domain.replace(prefix, '')
|
domain = domain.replace(prefix, '')
|
||||||
|
elif '/accounts/' in actor:
|
||||||
|
domain = actor.split('/accounts/')[0]
|
||||||
|
for prefix in prefixes:
|
||||||
|
domain = domain.replace(prefix, '')
|
||||||
|
elif '/channel/' in actor:
|
||||||
|
domain = actor.split('/channel/')[0]
|
||||||
|
for prefix in prefixes:
|
||||||
|
domain = domain.replace(prefix, '')
|
||||||
|
elif '/users/' not in actor:
|
||||||
|
domain = actor
|
||||||
|
for prefix in prefixes:
|
||||||
|
domain = domain.replace(prefix, '')
|
||||||
|
if '/' in actor:
|
||||||
|
domain = domain.split('/')[0]
|
||||||
else:
|
else:
|
||||||
if '/channel/' in actor:
|
domain = actor.split('/users/')[0]
|
||||||
domain = actor.split('/channel/')[0]
|
for prefix in prefixes:
|
||||||
for prefix in prefixes:
|
domain = domain.replace(prefix, '')
|
||||||
domain = domain.replace(prefix, '')
|
|
||||||
else:
|
|
||||||
if '/users/' not in actor:
|
|
||||||
domain = actor
|
|
||||||
for prefix in prefixes:
|
|
||||||
domain = domain.replace(prefix, '')
|
|
||||||
if '/' in actor:
|
|
||||||
domain = domain.split('/')[0]
|
|
||||||
else:
|
|
||||||
domain = actor.split('/users/')[0]
|
|
||||||
for prefix in prefixes:
|
|
||||||
domain = domain.replace(prefix, '')
|
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
portStr = domain.split(':')[1]
|
portStr = domain.split(':')[1]
|
||||||
if not portStr.isdigit():
|
if not portStr.isdigit():
|
||||||
|
|
|
@ -252,7 +252,7 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
||||||
print('Failed to download avatar image: ' + str(avatarUrl))
|
print('Failed to download avatar image: ' + str(avatarUrl))
|
||||||
print(e)
|
print(e)
|
||||||
prof = 'https://www.w3.org/ns/activitystreams'
|
prof = 'https://www.w3.org/ns/activitystreams'
|
||||||
if '/channel/' not in actor:
|
if '/channel/' not in actor or '/accounts/' not in actor:
|
||||||
sessionHeaders = {
|
sessionHeaders = {
|
||||||
'Accept': 'application/activity+json; profile="' + prof + '"'
|
'Accept': 'application/activity+json; profile="' + prof + '"'
|
||||||
}
|
}
|
||||||
|
@ -6281,6 +6281,7 @@ def htmlProfileAfterSearch(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
"""Show a profile page after a search for a fediverse address
|
"""Show a profile page after a search for a fediverse address
|
||||||
"""
|
"""
|
||||||
if '/users/' in profileHandle or \
|
if '/users/' in profileHandle or \
|
||||||
|
'/accounts/' in profileHandle or \
|
||||||
'/channel/' in profileHandle or \
|
'/channel/' in profileHandle or \
|
||||||
'/profile/' in profileHandle or \
|
'/profile/' in profileHandle or \
|
||||||
'/@' in profileHandle:
|
'/@' in profileHandle:
|
||||||
|
|
Loading…
Reference in New Issue