forked from indymedia/epicyon
Optionally limit skills searches to the instance
parent
7b6f2a6468
commit
8745f1e063
|
@ -2515,7 +2515,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
searchStr=searchStr.replace('*','').strip()
|
searchStr=searchStr.replace('*','').strip()
|
||||||
skillStr= \
|
skillStr= \
|
||||||
htmlSkillsSearch(self.server.baseDir,searchStr, \
|
htmlSkillsSearch(self.server.baseDir,searchStr, \
|
||||||
self.server.domainFull, \
|
self.server.instanceOnlySkillsSearch, \
|
||||||
maxPostsInFeed)
|
maxPostsInFeed)
|
||||||
if skillStr:
|
if skillStr:
|
||||||
msg=skillStr.encode('utf-8')
|
msg=skillStr.encode('utf-8')
|
||||||
|
@ -3135,7 +3135,8 @@ def runDaemon(projectVersion, \
|
||||||
noannounce=False,cw=False,ocapAlways=False, \
|
noannounce=False,cw=False,ocapAlways=False, \
|
||||||
useTor=False,maxReplies=64, \
|
useTor=False,maxReplies=64, \
|
||||||
domainMaxPostsPerDay=8640,accountMaxPostsPerDay=8640, \
|
domainMaxPostsPerDay=8640,accountMaxPostsPerDay=8640, \
|
||||||
allowDeletion=False,debug=False,unitTest=False) -> None:
|
allowDeletion=False,debug=False,unitTest=False, \
|
||||||
|
instanceOnlySkillsSearch=False) -> None:
|
||||||
if len(domain)==0:
|
if len(domain)==0:
|
||||||
domain='localhost'
|
domain='localhost'
|
||||||
if '.' not in domain:
|
if '.' not in domain:
|
||||||
|
@ -3187,6 +3188,7 @@ def runDaemon(projectVersion, \
|
||||||
httpd.salts={}
|
httpd.salts={}
|
||||||
httpd.tokens={}
|
httpd.tokens={}
|
||||||
httpd.tokensLookup={}
|
httpd.tokensLookup={}
|
||||||
|
httpd.instanceOnlySkillsSearch=instanceOnlySkillsSearch
|
||||||
httpd.acceptedCaps=["inbox:write","objects:read"]
|
httpd.acceptedCaps=["inbox:write","objects:read"]
|
||||||
if noreply:
|
if noreply:
|
||||||
httpd.acceptedCaps.append('inbox:noreply')
|
httpd.acceptedCaps.append('inbox:noreply')
|
||||||
|
|
|
@ -129,6 +129,9 @@ parser.add_argument('-f','--federate', nargs='+',dest='federationList', \
|
||||||
parser.add_argument("--debug", type=str2bool, nargs='?', \
|
parser.add_argument("--debug", type=str2bool, nargs='?', \
|
||||||
const=True, default=False, \
|
const=True, default=False, \
|
||||||
help="Show debug messages")
|
help="Show debug messages")
|
||||||
|
parser.add_argument("--instanceOnlySkillsSearch", type=str2bool, nargs='?', \
|
||||||
|
const=True, default=False, \
|
||||||
|
help="Skills searches only return results from this instance")
|
||||||
parser.add_argument("--http", type=str2bool, nargs='?', \
|
parser.add_argument("--http", type=str2bool, nargs='?', \
|
||||||
const=True, default=False, \
|
const=True, default=False, \
|
||||||
help="Use http only")
|
help="Use http only")
|
||||||
|
@ -1309,4 +1312,5 @@ runDaemon(__version__, \
|
||||||
args.noannounce,args.cw,ocapAlways, \
|
args.noannounce,args.cw,ocapAlways, \
|
||||||
useTor,args.maxReplies, \
|
useTor,args.maxReplies, \
|
||||||
args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \
|
args.domainMaxPostsPerDay,args.accountMaxPostsPerDay, \
|
||||||
args.allowdeletion,debug,False)
|
args.allowdeletion,debug,False, \
|
||||||
|
args.instanceOnlySkillsSearch)
|
||||||
|
|
6
tests.py
6
tests.py
|
@ -217,7 +217,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
|
||||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||||
useTor,maxReplies, \
|
useTor,maxReplies, \
|
||||||
domainMaxPostsPerDay,accountMaxPostsPerDay, \
|
domainMaxPostsPerDay,accountMaxPostsPerDay, \
|
||||||
allowDeletion,True,True)
|
allowDeletion,True,True,False)
|
||||||
|
|
||||||
def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
||||||
hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
||||||
|
@ -270,7 +270,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
|
||||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||||
useTor,maxReplies, \
|
useTor,maxReplies, \
|
||||||
domainMaxPostsPerDay,accountMaxPostsPerDay, \
|
domainMaxPostsPerDay,accountMaxPostsPerDay, \
|
||||||
allowDeletion,True,True)
|
allowDeletion,True,True,False)
|
||||||
|
|
||||||
def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
||||||
hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
||||||
|
@ -301,7 +301,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
|
||||||
runDaemon(__version__,"instanceId",False,path,domain,port,port, \
|
runDaemon(__version__,"instanceId",False,path,domain,port,port, \
|
||||||
httpPrefix,federationList, \
|
httpPrefix,federationList, \
|
||||||
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
noreply,nolike,nopics,noannounce,cw,ocapAlways, \
|
||||||
useTor,maxReplies,allowDeletion,True,True)
|
useTor,maxReplies,allowDeletion,True,True,False)
|
||||||
|
|
||||||
def testPostMessageBetweenServers():
|
def testPostMessageBetweenServers():
|
||||||
print('Testing sending message from one server to the inbox of another')
|
print('Testing sending message from one server to the inbox of another')
|
||||||
|
|
|
@ -284,7 +284,7 @@ def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: in
|
||||||
hashtagSearchForm+=htmlFooter()
|
hashtagSearchForm+=htmlFooter()
|
||||||
return hashtagSearchForm
|
return hashtagSearchForm
|
||||||
|
|
||||||
def htmlSkillsSearch(baseDir: str,skillsearch: str,domainFull: str,postsPerPage: int) -> str:
|
def htmlSkillsSearch(baseDir: str,skillsearch: str,instanceOnly: bool,postsPerPage: int) -> str:
|
||||||
"""Show a page containing search results for a skill
|
"""Show a page containing search results for a skill
|
||||||
"""
|
"""
|
||||||
if skillsearch.startswith('*'):
|
if skillsearch.startswith('*'):
|
||||||
|
@ -321,36 +321,37 @@ def htmlSkillsSearch(baseDir: str,skillsearch: str,domainFull: str,postsPerPage:
|
||||||
indexStr=skillLevelStr+';'+actor+';'+actorJson['name']+';'+actorJson['icon']['url']
|
indexStr=skillLevelStr+';'+actor+';'+actorJson['name']+';'+actorJson['icon']['url']
|
||||||
if indexStr not in results:
|
if indexStr not in results:
|
||||||
results.append(indexStr)
|
results.append(indexStr)
|
||||||
# search actor cache
|
if not instanceOnly:
|
||||||
for subdir, dirs, files in os.walk(baseDir+'/cache/actors/'):
|
# search actor cache
|
||||||
for f in files:
|
for subdir, dirs, files in os.walk(baseDir+'/cache/actors/'):
|
||||||
if not f.endswith('.json'):
|
for f in files:
|
||||||
continue
|
if not f.endswith('.json'):
|
||||||
if '@' not in f:
|
continue
|
||||||
continue
|
if '@' not in f:
|
||||||
if f.startswith('inbox@'):
|
continue
|
||||||
continue
|
if f.startswith('inbox@'):
|
||||||
actorFilename = os.path.join(subdir, f)
|
continue
|
||||||
with open(actorFilename, 'r') as fp:
|
actorFilename = os.path.join(subdir, f)
|
||||||
cachedActorJson=commentjson.load(fp)
|
with open(actorFilename, 'r') as fp:
|
||||||
if cachedActorJson.get('actor'):
|
cachedActorJson=commentjson.load(fp)
|
||||||
actorJson=cachedActorJson['actor']
|
if cachedActorJson.get('actor'):
|
||||||
if actorJson.get('id') and \
|
actorJson=cachedActorJson['actor']
|
||||||
actorJson.get('skills') and \
|
if actorJson.get('id') and \
|
||||||
actorJson.get('name') and \
|
actorJson.get('skills') and \
|
||||||
actorJson.get('icon'):
|
actorJson.get('name') and \
|
||||||
actor=actorJson['id']
|
actorJson.get('icon'):
|
||||||
for skillName,skillLevel in actorJson['skills'].items():
|
actor=actorJson['id']
|
||||||
skillName=skillName.lower()
|
for skillName,skillLevel in actorJson['skills'].items():
|
||||||
if skillName in skillsearch or skillsearch in skillName:
|
skillName=skillName.lower()
|
||||||
skillLevelStr=str(skillLevel)
|
if skillName in skillsearch or skillsearch in skillName:
|
||||||
if skillLevel<100:
|
skillLevelStr=str(skillLevel)
|
||||||
skillLevelStr='0'+skillLevelStr
|
if skillLevel<100:
|
||||||
if skillLevel<10:
|
skillLevelStr='0'+skillLevelStr
|
||||||
skillLevelStr='0'+skillLevelStr
|
if skillLevel<10:
|
||||||
indexStr=skillLevelStr+';'+actor+';'+actorJson['name']+';'+actorJson['icon']['url']
|
skillLevelStr='0'+skillLevelStr
|
||||||
if indexStr not in results:
|
indexStr=skillLevelStr+';'+actor+';'+actorJson['name']+';'+actorJson['icon']['url']
|
||||||
results.append(indexStr)
|
if indexStr not in results:
|
||||||
|
results.append(indexStr)
|
||||||
|
|
||||||
results.sort(reverse=True)
|
results.sort(reverse=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue