diff --git a/acceptreject.py b/acceptreject.py index 952b8382..4dc566f5 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -185,7 +185,9 @@ def receiveAcceptReject(session,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no actor') return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False diff --git a/announce.py b/announce.py index e8b15990..01442b16 100644 --- a/announce.py +++ b/announce.py @@ -269,7 +269,9 @@ def createAnnounce(session,baseDir: str,federationList: [], \ announceNickname=None announceDomain=None announcePort=None - if '/users/' in objectUrl or '/profile/' in objectUrl: + if '/users/' in objectUrl or \ + '/channel/' in objectUrl or \ + '/profile/' in objectUrl: announceNickname=getNicknameFromActor(objectUrl) announceDomain,announcePort=getDomainFromActor(objectUrl) @@ -380,7 +382,9 @@ def undoAnnounce(session,baseDir: str,federationList: [], \ announceNickname=None announceDomain=None announcePort=None - if '/users/' in objectUrl or '/profile/' in objectUrl: + if '/users/' in objectUrl or \ + '/channel/' in objectUrl or \ + '/profile/' in objectUrl: announceNickname=getNicknameFromActor(objectUrl) announceDomain,announcePort=getDomainFromActor(objectUrl) diff --git a/auth.py b/auth.py index 2aa3d5a2..80a74259 100644 --- a/auth.py +++ b/auth.py @@ -46,7 +46,9 @@ 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 and '/profile/' not in path: + if '/users/' not in path and \ + '/channel/' 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 ebca4cea..f6c5f1fe 100644 --- a/blocking.py +++ b/blocking.py @@ -333,7 +333,9 @@ def outboxBlock(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s block object is not a status') return - if '/users/' not in messageId and '/profile/' not in messageId: + if '/users/' not in messageId and \ + '/channel/' not in messageId and \ + '/profile/' not in messageId: if debug: print('DEBUG: c2s block object has no nickname') return @@ -408,7 +410,9 @@ def outboxUndoBlock(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s undo block object is not a status') return - if '/users/' not in messageId and '/profile/' not in messageId: + if '/users/' not in messageId and \ + '/channel/' 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 74dd7487..0f737998 100644 --- a/delete.py +++ b/delete.py @@ -68,7 +68,9 @@ def createDelete(session,baseDir: str,federationList: [], \ deleteNickname=None deleteDomain=None deletePort=None - if '/users/' in objectUrl or '/profile/' in objectUrl: + if '/users/' in objectUrl or \ + '/channel/' in objectUrl or \ + '/profile/' in objectUrl: deleteNickname=getNicknameFromActor(objectUrl) deleteDomain,deletePort=getDomainFromActor(objectUrl) @@ -242,7 +244,9 @@ def outboxDelete(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s delete object is not a status') return - if '/users/' not in messageId and '/profile/' not in messageId: + if '/users/' not in messageId and \ + '/channel/' 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 96c1f204..74ccfb6e 100644 --- a/epicyon.py +++ b/epicyon.py @@ -846,15 +846,20 @@ 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 and '/profile/' not in args.actor: + if '/users/' not in args.actor and \ + '/channel/' not in args.actor and \ + '/profile/' not in args.actor: print('Expected actor format: https://domain/@nick or https://domain/users/nick') sys.exit() if '/users/' in args.actor: nickname=args.actor.split('/users/')[1].replace('\n','') domain=args.actor.split('/users/')[0] - else: + elif '/profile/' in args.actor: nickname=args.actor.split('/profile/')[1].replace('\n','') domain=args.actor.split('/profile/')[0] + else: + nickname=args.actor.split('/channel/')[1].replace('\n','') + domain=args.actor.split('/channel/')[0] else: # format: @nick@domain if '@' not in args.actor: @@ -884,10 +889,14 @@ if args.actor: print('Unable to webfinger '+nickname+'@'+domain) sys.exit() + pprint(wfRequest) + personUrl=None if wfRequest.get('errors'): print('wfRequest error: '+str(wfRequest['errors'])) - if '/users/' in args.actor: + if '/users/' in args.actor or \ + '/profile/' in args.actor or \ + '/channel/' in args.actor: personUrl=originalActor else: sys.exit() @@ -896,8 +905,10 @@ if args.actor: if not personUrl: personUrl = getUserUrl(wfRequest) if nickname==domain: - personUrl=personUrl.replace('/users/','/actor/') + personUrl=personUrl.replace('/users/','/actor/').replace('/channel/','/actor/').replace('/profile/','/actor/') #print('personUrl: '+personUrl) + if '/channel/' in personUrl: + asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} personJson = getJson(session,personUrl,asHeader,None,__version__,httpPrefix,None) if personJson: pprint(personJson) diff --git a/follow.py b/follow.py index 8bc9f696..90c434b0 100644 --- a/follow.py +++ b/follow.py @@ -439,7 +439,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'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor') return False @@ -463,7 +465,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'] and '/profile/' not in messageJson['object']: + if '/users/' not in messageJson['object'] and \ + '/channel/' not in messageJson['object'] and \ + '/profile/' not in messageJson['object']: if debug: print('DEBUG: "users" or "profile" not found within object') return False diff --git a/inbox.py b/inbox.py index 62d263de..a438995f 100644 --- a/inbox.py +++ b/inbox.py @@ -553,7 +553,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'] and '/profile/' not in messageJson['object']['actor']: + if '/users/' not in messageJson['object']['actor'] and \ + '/channel/' not in messageJson['object']['actor'] and \ + '/profile/' not in messageJson['object']['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor within object') return False @@ -612,7 +614,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'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor') return False @@ -663,11 +667,13 @@ def personReceiveUpdate(baseDir: str, \ if actor not in personJson['id']: actor=updateDomainFull+'/profile/'+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+'/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 if updateDomainFull==domainFull: if debug: print('DEBUG: You can only receive actor updates for domains other than your own') @@ -763,7 +769,9 @@ def receiveUpdate(session,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' object has no type') return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False @@ -827,7 +835,9 @@ def receiveLike(session,handle: str,isGroup: bool,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no "to" list') return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False @@ -876,7 +886,9 @@ def receiveUndoLike(session,handle: str,isGroup: bool,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' like object is not a string') return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']+' like') return False @@ -937,7 +949,9 @@ def receiveDelete(session,handle: str,isGroup: bool,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no "to" list') return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']) return False @@ -995,11 +1009,15 @@ def receiveAnnounce(session,handle: str,isGroup: bool,baseDir: str, \ if debug: print('DEBUG: '+messageJson['type']+' has no "to" list') return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: 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 '/users/' not in messageJson['object'] and \ + '/channel/' not in messageJson['object'] and \ + '/profile/' not in messageJson['object']: if debug: print('DEBUG: "users" or "profile" missing in '+messageJson['type']) return False @@ -1042,7 +1060,9 @@ def receiveAnnounce(session,handle: str,isGroup: bool,baseDir: str, \ if postJsonObject['object'].get('attributedTo'): lookupActor=postJsonObject['object']['attributedTo'] if lookupActor: - if '/users/' in lookupActor or '/profile/' in lookupActor: + if '/users/' in lookupActor or \ + '/channel/' in lookupActor or \ + '/profile/' in lookupActor: if '/statuses/' in lookupActor: lookupActor=lookupActor.split('/statuses/')[0] @@ -1086,7 +1106,9 @@ def receiveUndoAnnounce(session,handle: str,isGroup: bool,baseDir: str, \ return False if messageJson['object']['type']!='Announce': return False - if '/users/' not in messageJson['actor'] and '/profile/' not in messageJson['actor']: + if '/users/' not in messageJson['actor'] and \ + '/channel/' not in messageJson['actor'] and \ + '/profile/' not in messageJson['actor']: if debug: print('DEBUG: "users" or "profile" missing from actor in '+messageJson['type']+' announce') return False @@ -1249,7 +1271,9 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str,domain: str,pe lookupActor=postJsonObject['object']['inReplyTo'] if lookupActor: - if '/users/' in lookupActor or '/profile/' in lookupActor: + if '/users/' in lookupActor or \ + '/channel/' in lookupActor or \ + '/profile/' in lookupActor: if '/statuses/' in lookupActor: lookupActor=lookupActor.split('/statuses/')[0] diff --git a/like.py b/like.py index 9bd14e9d..ceaafda3 100644 --- a/like.py +++ b/like.py @@ -211,7 +211,9 @@ def like(session,baseDir: str,federationList: [],nickname: str,domain: str,port: likedPostNickname=None likedPostDomain=None likedPostPort=None - if '/users/' in objectUrl or '/profile/' in objectUrl: + if '/users/' in objectUrl or \ + '/channel/' in objectUrl or \ + '/profile/' in objectUrl: likedPostNickname=getNicknameFromActor(objectUrl) likedPostDomain,likedPostPort=getDomainFromActor(objectUrl) @@ -308,7 +310,9 @@ def undolike(session,baseDir: str,federationList: [],nickname: str,domain: str,p likedPostNickname=None likedPostDomain=None likedPostPort=None - if '/users/' in objectUrl or '/profile/' in objectUrl: + if '/users/' in objectUrl or \ + '/channel/' in objectUrl or \ + '/profile/' in objectUrl: likedPostNickname=getNicknameFromActor(objectUrl) likedPostDomain,likedPostPort=getDomainFromActor(objectUrl) @@ -544,7 +548,9 @@ def outboxLike(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s like object is not a status') return - if '/users/' not in messageId and '/profile/' not in messageId: + if '/users/' not in messageId and \ + '/channel/' not in messageId and \ + '/profile/' not in messageId: if debug: print('DEBUG: c2s like object has no nickname') return @@ -599,7 +605,9 @@ def outboxUndoLike(baseDir: str,httpPrefix: str, \ if debug: print('DEBUG: c2s undo like object is not a status') return - if '/users/' not in messageId and '/profile/' not in messageId: + if '/users/' not in messageId and \ + '/channel/' not in messageId and \ + '/profile/' not in messageId: if debug: print('DEBUG: c2s undo like object has no nickname') return diff --git a/posts.py b/posts.py index 5cc071a1..4286ed14 100644 --- a/posts.py +++ b/posts.py @@ -119,7 +119,9 @@ def getUserUrl(wfRequest) -> str: for link in wfRequest['links']: if link.get('type') and link.get('href'): if link['type'] == 'application/activity+json': - if '/users/' in link['href'] or '/profile/' in link['href']: + if '/users/' in link['href'] or \ + '/profile/' in link['href'] or \ + '/channel/' in link['href']: return link['href'] else: print('Webfinger activity+json does not contain a valid actor') @@ -168,6 +170,8 @@ def getPersonBox(baseDir: str,session,wfRequest: {},personCache: {}, \ return None,None,None,None,None,None,None,None personJson = getPersonFromCache(baseDir,personUrl,personCache) if not personJson: + if '/channel/' in personUrl: + asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} personJson = getJson(session,personUrl,asHeader,None, \ projectVersion,httpPrefix,domain) if not personJson: @@ -228,6 +232,8 @@ def getPosts(session,outboxUrl: str,maxPosts: int, \ if not outboxUrl: return personPosts asHeader = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'} + if '/outbox/' in outboxUrl: + asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} if raw: result = [] i = 0 @@ -2410,7 +2416,9 @@ def downloadAnnounce(session,baseDir: str,httpPrefix: str,nickname: str,domain: if '/statuses/' not in announcedJson['id']: rejectAnnounce(announceFilename) return None - if '/users/' not in announcedJson['id'] and '/profile/' not in announcedJson['id']: + if '/users/' not in announcedJson['id'] and \ + '/channel/' not in announcedJson['id'] and \ + '/profile/' not in announcedJson['id']: rejectAnnounce(announceFilename) return None if not announcedJson.get('type'): diff --git a/utils.py b/utils.py index d3d56d2b..8eab88e9 100644 --- a/utils.py +++ b/utils.py @@ -115,6 +115,12 @@ def getNicknameFromActor(actor: str) -> str: return nickStr else: return nickStr.split('/')[0] + if '/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: nickStr=actor.split('/@')[1] @@ -135,12 +141,15 @@ def getDomainFromActor(actor: str) -> (str,int): if '/profile/' in actor: domain = actor.split('/profile/')[0].replace('https://','').replace('http://','').replace('dat://','') else: - if '/users/' not in actor: - domain = actor.replace('https://','').replace('http://','').replace('dat://','') - if '/' in actor: - domain=domain.split('/')[0] + if '/channel/' in actor: + domain = actor.split('/channel/')[0].replace('https://','').replace('http://','').replace('dat://','') else: - domain = actor.split('/users/')[0].replace('https://','').replace('http://','').replace('dat://','') + if '/users/' not in actor: + domain = actor.replace('https://','').replace('http://','').replace('dat://','') + if '/' in actor: + domain=domain.split('/')[0] + else: + domain = actor.split('/users/')[0].replace('https://','').replace('http://','').replace('dat://','') if ':' in domain: port=int(domain.split(':')[1]) domain=domain.split(':')[0] @@ -326,7 +335,7 @@ def validNickname(domain: str,nickname: str) -> bool: return False if nickname==domain: return False - reservedNames=['inbox','dm','outbox','following','public','followers','capabilities','calendar','tlreplies','tlmedia','moderation'] + reservedNames=['inbox','dm','outbox','following','public','followers','profile','channel','capabilities','calendar','tlreplies','tlmedia','moderation'] if nickname in reservedNames: return False return True