diff --git a/acceptreject.py b/acceptreject.py index e7051f7d..dcfdeb22 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -202,6 +202,7 @@ def receiveAcceptReject(session, baseDir: str, print('DEBUG: ' + messageJson['type'] + ' has no actor') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: diff --git a/announce.py b/announce.py index f0575ea6..00804d2b 100644 --- a/announce.py +++ b/announce.py @@ -147,6 +147,7 @@ def createAnnounce(session, baseDir: str, federationList: [], announceDomain = None announcePort = None if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: announceNickname = getNicknameFromActor(objectUrl) @@ -263,6 +264,7 @@ def undoAnnounce(session, baseDir: str, federationList: [], announceDomain = None announcePort = None if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: announceNickname = getNicknameFromActor(objectUrl) diff --git a/auth.py b/auth.py index 8297aa81..d2aab591 100644 --- a/auth.py +++ b/auth.py @@ -57,6 +57,7 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str, 'contain a space character') return False if '/users/' not in path and \ + '/accounts/' not in path and \ '/channel/' not in path and \ '/profile/' not in path: if debug: diff --git a/blocking.py b/blocking.py index 070b4c83..0c57af78 100644 --- a/blocking.py +++ b/blocking.py @@ -220,6 +220,7 @@ def outboxBlock(baseDir: str, httpPrefix: str, print('DEBUG: c2s block object is not a status') return if '/users/' not in messageId and \ + '/accounts/' not in messageId and \ '/channel/' not in messageId and \ '/profile/' not in messageId: if debug: @@ -298,6 +299,7 @@ def outboxUndoBlock(baseDir: str, httpPrefix: str, print('DEBUG: c2s undo block object is not a status') return if '/users/' not in messageId and \ + '/accounts/' not in messageId and \ '/channel/' not in messageId and \ '/profile/' not in messageId: if debug: diff --git a/bookmarks.py b/bookmarks.py index 22387d39..b7f1fa82 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -262,6 +262,7 @@ def bookmark(recentPostsCache: {}, bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm) else: if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: ou = objectUrl @@ -362,6 +363,7 @@ def undoBookmark(recentPostsCache: {}, bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm) else: if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: ou = objectUrl diff --git a/daemon.py b/daemon.py index 05d0bf91..578348ec 100644 --- a/daemon.py +++ b/daemon.py @@ -5914,7 +5914,7 @@ class PubServer(BaseHTTPRequestHandler): return self._400() 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 if not self._cryptoAPIQuery(): self._400() diff --git a/delete.py b/delete.py index e26002fe..f7758544 100644 --- a/delete.py +++ b/delete.py @@ -67,6 +67,7 @@ def createDelete(session, baseDir: str, federationList: [], deleteDomain = None deletePort = None if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: deleteNickname = getNicknameFromActor(objectUrl) @@ -262,6 +263,7 @@ def outboxDelete(baseDir: str, httpPrefix: str, print('DEBUG: c2s delete object is not a status') return if '/users/' not in messageId and \ + '/accounts/' not in messageId and \ '/channel/' not in messageId and \ '/profile/' not in messageId: if debug: diff --git a/epicyon.py b/epicyon.py index 1ca654c6..c7809ecb 100644 --- a/epicyon.py +++ b/epicyon.py @@ -1130,6 +1130,7 @@ if args.actor: args.actor = args.actor.replace(prefix, '') args.actor = args.actor.replace('/@', '/users/') if '/users/' not in args.actor and \ + '/accounts/' not in args.actor and \ '/channel/' not in args.actor and \ '/profile/' not in args.actor: print('Expected actor format: ' + @@ -1143,10 +1144,14 @@ if args.actor: nickname = args.actor.split('/profile/')[1] nickname = nickname.replace('\n', '').replace('\r', '') domain = args.actor.split('/profile/')[0] - else: + elif '/channel/' in args.actor: nickname = args.actor.split('/channel/')[1] nickname = nickname.replace('\n', '').replace('\r', '') 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: # format: @nick@domain if '@' not in args.actor: @@ -1198,6 +1203,7 @@ if args.actor: if wfRequest.get('errors'): print('wfRequest error: ' + str(wfRequest['errors'])) if '/users/' in args.actor or \ + '/accounts/' in args.actor or \ '/profile/' in args.actor or \ '/channel/' in args.actor: personUrl = originalActor @@ -1212,6 +1218,7 @@ if args.actor: personUrl = getUserUrl(wfRequest) if nickname == domain: personUrl = personUrl.replace('/users/', '/actor/') + personUrl = personUrl.replace('/accounts/', '/actor/') personUrl = personUrl.replace('/channel/', '/actor/') personUrl = personUrl.replace('/profile/', '/actor/') if not personUrl: @@ -1221,7 +1228,7 @@ if args.actor: asHeader = { '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' asHeader = { 'Accept': 'application/ld+json; profile="' + profileStr + '"' diff --git a/follow.py b/follow.py index 06a63655..3c6c6e1d 100644 --- a/follow.py +++ b/follow.py @@ -555,6 +555,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str, print('DEBUG: follow request has no actor') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -582,6 +583,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str, if not messageJson.get('to'): messageJson['to'] = messageJson['object'] if '/users/' not in messageJson['object'] and \ + '/accounts/' not in messageJson['object'] and \ '/channel/' not in messageJson['object'] and \ '/profile/' not in messageJson['object']: if debug: diff --git a/happening.py b/happening.py index dce6f671..438ffa3a 100644 --- a/happening.py +++ b/happening.py @@ -64,7 +64,7 @@ def saveEvent(baseDir: str, handle: str, postId: str, if eventMonthNumber < 1 or eventMonthNumber > 12: return False eventDayOfMonth = int(eventTime.strftime("%d")) - if eventDayOfMonth < 1or eventDayOfMonth > 31: + if eventDayOfMonth < 1 or eventDayOfMonth > 31: return False if eventJson.get('name') and eventJson.get('actor') and \ diff --git a/inbox.py b/inbox.py index c4b0733e..692b89c1 100644 --- a/inbox.py +++ b/inbox.py @@ -661,6 +661,7 @@ def receiveUndoFollow(session, baseDir: str, httpPrefix: str, print('DEBUG: follow request has no actor within object') return False if '/users/' not in messageJson['object']['actor'] and \ + '/accounts/' not in messageJson['object']['actor'] and \ '/channel/' not in messageJson['object']['actor'] and \ '/profile/' not in messageJson['object']['actor']: if debug: @@ -735,6 +736,7 @@ def receiveUndo(session, baseDir: str, httpPrefix: str, print('DEBUG: follow request has no actor') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -792,11 +794,13 @@ def personReceiveUpdate(baseDir: str, if actor not in personJson['id']: actor = updateDomainFull + '/channel/' + updateNickname if actor not in personJson['id']: - if debug: - print('actor: ' + actor) - print('id: ' + personJson['id']) - print('DEBUG: Actor does not match id') - return False + actor = updateDomainFull + '/accounts/' + updateNickname + if actor not in personJson['id']: + if debug: + print('actor: ' + actor) + print('id: ' + personJson['id']) + print('DEBUG: Actor does not match id') + return False if updateDomainFull == domainFull: if debug: 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') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -1008,6 +1013,7 @@ def receiveLike(recentPostsCache: {}, print('DEBUG: ' + messageJson['type'] + ' has no "to" list') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -1076,6 +1082,7 @@ def receiveUndoLike(recentPostsCache: {}, ' like object is not a string') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -1288,6 +1295,7 @@ def receiveDelete(session, handle: str, isGroup: bool, baseDir: str, print('DEBUG: ' + messageJson['type'] + ' has no "to" list') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -1358,6 +1366,7 @@ def receiveAnnounce(recentPostsCache: {}, print('DEBUG: ' + messageJson['type'] + ' has no "to" list') return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -1366,6 +1375,7 @@ def receiveAnnounce(recentPostsCache: {}, messageJson['type']) return False if '/users/' not in messageJson['object'] and \ + '/accounts/' not in messageJson['object'] and \ '/channel/' not in messageJson['object'] and \ '/profile/' not in messageJson['object']: if debug: @@ -1434,6 +1444,7 @@ def receiveAnnounce(recentPostsCache: {}, lookupActor = attrib if lookupActor: if '/users/' in lookupActor or \ + '/accounts/' in lookupActor or \ '/channel/' in lookupActor or \ '/profile/' in lookupActor: if '/statuses/' in lookupActor: @@ -1485,6 +1496,7 @@ def receiveUndoAnnounce(recentPostsCache: {}, if messageJson['object']['type'] != 'Announce': return False if '/users/' not in messageJson['actor'] and \ + '/accounts/' not in messageJson['actor'] and \ '/channel/' not in messageJson['actor'] and \ '/profile/' not in messageJson['actor']: if debug: @@ -1679,6 +1691,7 @@ def obtainAvatarForReplyPost(session, baseDir: str, httpPrefix: str, return if not ('/users/' in lookupActor or + '/accounts/' in lookupActor or '/channel/' in lookupActor or '/profile/' in lookupActor): return diff --git a/like.py b/like.py index dde8bd8b..f3d127dc 100644 --- a/like.py +++ b/like.py @@ -90,6 +90,7 @@ def like(recentPostsCache: {}, likedPostDomain, likedPostPort = getDomainFromActor(actorLiked) else: if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: likedPostNickname = getNicknameFromActor(objectUrl) @@ -193,6 +194,7 @@ def undolike(recentPostsCache: {}, likedPostDomain, likedPostPort = getDomainFromActor(actorLiked) else: if '/users/' in objectUrl or \ + '/accounts/' in objectUrl or \ '/channel/' in objectUrl or \ '/profile/' in objectUrl: likedPostNickname = getNicknameFromActor(objectUrl) diff --git a/posts.py b/posts.py index 1aa7f8b1..05b081e7 100644 --- a/posts.py +++ b/posts.py @@ -136,6 +136,7 @@ def getUserUrl(wfRequest: {}) -> str: if link.get('type') and link.get('href'): if link['type'] == 'application/activity+json': if not ('/users/' in link['href'] or + '/accounts/' in link['href'] or '/profile/' in link['href'] or '/channel/' in link['href']): print('Webfinger activity+json contains ' + @@ -207,7 +208,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {}, return None, None, None, None, None, None, None, None personJson = getPersonFromCache(baseDir, personUrl, personCache) if not personJson: - if '/channel/' in personUrl: + if '/channel/' in personUrl or '/accounts/' in personUrl: asHeader = { 'Accept': 'application/ld+json; profile="' + profileStr + '"' } @@ -3188,7 +3189,8 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str, asHeader = { 'Accept': 'application/activity+json; profile="' + profileStr + '"' } - if '/channel/' in postJsonObject['actor']: + if '/channel/' in postJsonObject['actor'] or \ + '/accounts/' in postJsonObject['actor']: asHeader = { 'Accept': 'application/ld+json; profile="' + profileStr + '"' } @@ -3238,6 +3240,7 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str, rejectAnnounce(announceFilename) return None if '/users/' not in announcedJson['id'] and \ + '/accounts/' not in announcedJson['id'] and \ '/channel/' not in announcedJson['id'] and \ '/profile/' not in announcedJson['id']: rejectAnnounce(announceFilename) diff --git a/utils.py b/utils.py index abdb67be..298ed54f 100644 --- a/utils.py +++ b/utils.py @@ -222,14 +222,20 @@ def getNicknameFromActor(actor: str) -> str: return nickStr else: return nickStr.split('/')[0] - if '/channel/' in actor: + elif '/channel/' in actor: nickStr = actor.split('/channel/')[1].replace('@', '') if '/' not in nickStr: return nickStr else: return nickStr.split('/')[0] - # https://domain/@nick - if '/@' in actor: + elif '/accounts/' 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] if '/' in nickStr: nickStr = nickStr.split('/')[0] @@ -251,22 +257,24 @@ def getDomainFromActor(actor: str) -> (str, int): domain = actor.split('/profile/')[0] for prefix in prefixes: 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: - if '/channel/' in actor: - domain = actor.split('/channel/')[0] - for prefix in prefixes: - 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, '') + domain = actor.split('/users/')[0] + for prefix in prefixes: + domain = domain.replace(prefix, '') if ':' in domain: portStr = domain.split(':')[1] if not portStr.isdigit(): diff --git a/webinterface.py b/webinterface.py index c762e6ca..6a84dc8a 100644 --- a/webinterface.py +++ b/webinterface.py @@ -252,7 +252,7 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str, print('Failed to download avatar image: ' + str(avatarUrl)) print(e) prof = 'https://www.w3.org/ns/activitystreams' - if '/channel/' not in actor: + if '/channel/' not in actor or '/accounts/' not in actor: sessionHeaders = { '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 """ if '/users/' in profileHandle or \ + '/accounts/' in profileHandle or \ '/channel/' in profileHandle or \ '/profile/' in profileHandle or \ '/@' in profileHandle: