From 1b10d7ef4b13066db3c2d4bf4ac2f87555ded2d9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 9 Jul 2019 10:20:04 +0100 Subject: [PATCH] Removed unused capabilities functions --- capabilities.py | 16 ---------------- follow.py | 6 ------ posts.py | 4 ---- utils.py | 4 ---- 4 files changed, 30 deletions(-) diff --git a/capabilities.py b/capabilities.py index 7da73eb2..597bcd01 100644 --- a/capabilities.py +++ b/capabilities.py @@ -151,19 +151,3 @@ def capabilitiesGrantedSave(baseDir :str,nickname :str,domain :str,ocap: {}) -> with open(ocapFilename, 'w') as fp: commentjson.dump(ocap, fp, indent=4, sort_keys=False) return True - -def isCapable(actor: str,ocapGranted: {},capability: str) -> bool: - # is the given actor capable of using the current resource? - for id,ocap in ocapGranted.items(): - if ocap['scope'] in actor: - if capability in ocap['capability']: - return True - return False - -def isCapableId(id: str,ocapGranted: {},capability: str) -> bool: - # is the given id capable of using the current resource? - if ocapGranted.get(id): - if ocapGranted['id']['scope'] in actor: - if capability in ocapGranted['id']['capability']: - return True - return False diff --git a/follow.py b/follow.py index 75ae542d..daeeecdd 100644 --- a/follow.py +++ b/follow.py @@ -18,7 +18,6 @@ from utils import getNicknameFromActor from utils import getStatusNumber from utils import followPerson from posts import sendSignedJson -from capabilities import isCapable from acceptreject import createAccept def getFollowersOfPerson(baseDir: str, \ @@ -322,11 +321,6 @@ def sendFollowRequest(session,baseDir: str, \ if followPort!=80 and followPort!=443: requestDomain=followDomain+':'+str(followPort) - # check that we are capable - if ocapGranted: - if not isCapable(followActor,ocapGranted,'inbox:write'): - return None - statusNumber,published = getStatusNumber() followedId=followHttpPrefix+'://'+requestDomain+'/users/'+followNickname diff --git a/posts.py b/posts.py index b5a19ddd..7ac9d0f0 100644 --- a/posts.py +++ b/posts.py @@ -30,7 +30,6 @@ from httpsig import createSignedHeader from utils import getStatusNumber from utils import createPersonDir from utils import urlPermitted -from capabilities import isCapable from capabilities import getOcapFilename try: from BeautifulSoup import BeautifulSoup @@ -344,9 +343,6 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ sensitive=True if not clientToServer: actorUrl=httpPrefix+'://'+domain+'/users/'+nickname - if ocapGranted: - if not isCapable(actorUrl,ocapGranted,'inbox:write'): - return None # if capabilities have been granted for this actor # then get the corresponding id diff --git a/utils.py b/utils.py index 49cb6e13..3a0a969d 100644 --- a/utils.py +++ b/utils.py @@ -8,7 +8,6 @@ __status__ = "Production" import os import datetime -#from capabilities import isCapable def getStatusNumber() -> (str,str): """Returns the status number and published date @@ -50,9 +49,6 @@ def domainPermitted(domain: str, federationList: []): return False def urlPermitted(url: str, federationList: [],ocapGranted: {},capability: str): - #if ocapGranted: - # if not isCapable(url,ocapGranted,capability): - # return False if len(federationList)==0: return True for domain in federationList: