From cd5af800c2caa67f4ca926a73cbd2268b54397e6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 9 Sep 2019 10:41:31 +0100 Subject: [PATCH] Allow profile in path --- acceptreject.py | 4 ++-- auth.py | 2 +- blocking.py | 4 ++-- delete.py | 2 +- epicyon.py | 10 +++++++--- follow.py | 8 ++++---- inbox.py | 36 ++++++++++++++++++++---------------- like.py | 4 ++-- 8 files changed, 39 insertions(+), 31 deletions(-) diff --git a/acceptreject.py b/acceptreject.py index c40129bda..952b83821 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -185,9 +185,9 @@ def receiveAcceptReject(session,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no actor') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']) + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False domain,tempPort=getDomainFromActor(messageJson['actor']) if not domainPermitted(domain,federationList): diff --git a/auth.py b/auth.py index 9972b8fda..2aa3d5a23 100644 --- a/auth.py +++ b/auth.py @@ -46,7 +46,7 @@ def authorizeBasic(baseDir: str,path: str,authHeader: str,debug: bool) -> bool: if debug: print('DEBUG: Authorixation header does not contain a space character') return False - if '/users/' not in path: + if '/users/' not in path and '/profile/' not in path: if debug: print('DEBUG: Path for Authorization does not contain a user') return False diff --git a/blocking.py b/blocking.py index f1f000930..bbe9d3f9f 100644 --- a/blocking.py +++ b/blocking.py @@ -322,7 +322,7 @@ def outboxBlock(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s block object is not a status') return - if '/users/' not in messageId: + if '/users/' not in messageId and '/profile/' not in messageId: if debug: print('DEBUG: c2s block object has no nickname') return @@ -397,7 +397,7 @@ def outboxUndoBlock(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s undo block object is not a status') return - if '/users/' not in messageId: + if '/users/' not in messageId and '/profile/' not in messageId: if debug: print('DEBUG: c2s undo block object has no nickname') return diff --git a/delete.py b/delete.py index 389b68717..775255015 100644 --- a/delete.py +++ b/delete.py @@ -241,7 +241,7 @@ def outboxDelete(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s delete object is not a status') return - if '/users/' not in messageId: + if '/users/' not in messageId and '/profile/' not in messageId: if debug: print('DEBUG: c2s delete object has no nickname') return diff --git a/epicyon.py b/epicyon.py index 6e297e74a..0e6b77a1c 100644 --- a/epicyon.py +++ b/epicyon.py @@ -820,11 +820,15 @@ if args.actor: if '/@' in args.actor or '/users/' in args.actor or args.actor.startswith('http') or args.actor.startswith('dat'): # format: https://domain/@nick args.actor=args.actor.replace('https://','').replace('http://','').replace('dat://','').replace('/@','/users/') - if '/users/' not in args.actor: + if '/users/' not in args.actor and '/profile/' not in args.actor: print('Expected actor format: https://domain/@nick or https://domain/users/nick') sys.exit() - nickname=args.actor.split('/users/')[1].replace('\n','') - domain=args.actor.split('/users/')[0] + if '/users/' in args.actor: + nickname=args.actor.split('/users/')[1].replace('\n','') + domain=args.actor.split('/users/')[0] + else: + nickname=args.actor.split('/profile/')[1].replace('\n','') + domain=args.actor.split('/profile/')[0] else: # format: @nick@domain if '@' not in args.actor: diff --git a/follow.py b/follow.py index 3d715ffa2..911df8972 100644 --- a/follow.py +++ b/follow.py @@ -373,9 +373,9 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: follow request has no actor') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor') + print('DEBUG: "users" or "profile" missing from actor') return False domain,tempPort=getDomainFromActor(messageJson['actor']) fromPort=port @@ -397,9 +397,9 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \ if not messageJson.get('to'): messageJson['to']=messageJson['object'] handle=nickname.lower()+'@'+domain.lower() - if '/users/' not in messageJson['object']: + if '/users/' not in messageJson['object'] and '/profile/' not in messageJson['object']: if debug: - print('DEBUG: "users" not found within object') + print('DEBUG: "users" or "profile" not found within object') return False domainToFollow,tempPort=getDomainFromActor(messageJson['object']) if not domainPermitted(domainToFollow,federationList): diff --git a/inbox.py b/inbox.py index 8205aa740..2b4fe073c 100644 --- a/inbox.py +++ b/inbox.py @@ -505,9 +505,9 @@ def receiveUndoFollow(session,baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: follow request has no actor within object') return False - if '/users/' not in messageJson['object']['actor']: + if '/users/' not in messageJson['object']['actor'] and '/profile/' not in messageJson['object']['actor']: if debug: - print('DEBUG: "users" missing from actor within object') + print('DEBUG: "users" or "profile" missing from actor within object') return False if messageJson['object']['actor'] != messageJson['actor']: if debug: @@ -564,9 +564,9 @@ def receiveUndo(session,baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: follow request has no actor') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor') + print('DEBUG: "users" or "profile" missing from actor') return False if not messageJson.get('object'): if debug: @@ -679,9 +679,9 @@ def receiveUpdate(session,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' object has no type') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']) + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False if messageJson['object']['type']=='Person' or \ @@ -742,9 +742,9 @@ def receiveLike(session,handle: str,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no "to" list') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']) + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False if '/statuses/' not in messageJson['object']: if debug: @@ -791,9 +791,9 @@ def receiveUndoLike(session,handle: str,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' like object is not a string') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']+' like') + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']+' like') return False if '/statuses/' not in messageJson['object']['object']: if debug: @@ -852,9 +852,9 @@ def receiveDelete(session,handle: str,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no "to" list') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']) + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False if '/statuses/' not in messageJson['object']: if debug: @@ -906,9 +906,13 @@ def receiveAnnounce(session,handle: str,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no "to" list') return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']) + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) + return False + if '/users/' not in messageJson['object'] and '/profile/' not in messageJson['object']: + if debug: + print('DEBUG: "users" or "profile" missing in '+messageJson['type']) return False if '/statuses/' not in messageJson['object']: if debug: @@ -949,9 +953,9 @@ def receiveUndoAnnounce(session,handle: str,baseDir: str, \ return False if messageJson['object']['type']!='Announce': return False - if '/users/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: if debug: - print('DEBUG: "users" missing from actor in '+messageJson['type']+' announce') + print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']+' announce') return False if '/statuses/' not in messageJson['object']: if debug: diff --git a/like.py b/like.py index b1441115e..8a5533afb 100644 --- a/like.py +++ b/like.py @@ -505,7 +505,7 @@ def outboxLike(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s like object is not a status') return - if '/users/' not in messageId: + if '/users/' not in messageId and '/profile/' not in messageId: if debug: print('DEBUG: c2s like object has no nickname') return @@ -560,7 +560,7 @@ def outboxUndoLike(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s undo like object is not a status') return - if '/users/' not in messageId: + if '/users/' not in messageId and '/profile/' not in messageId: if debug: print('DEBUG: c2s undo like object has no nickname') return