forked from indymedia/epicyon
Move function
parent
9ba6edd5c7
commit
3a8801e544
|
@ -17,7 +17,6 @@ from webfinger import webfingerLookup
|
|||
from webfinger import webfingerHandle
|
||||
from person import personLookup
|
||||
from person import personBoxJson
|
||||
from posts import getPersonPubKey
|
||||
from posts import outboxMessageCreateWrap
|
||||
from posts import savePostToBox
|
||||
from inbox import inboxPermittedMessage
|
||||
|
|
|
@ -16,7 +16,6 @@ from posts import deleteAllPosts
|
|||
from posts import createOutbox
|
||||
from posts import archivePosts
|
||||
from posts import sendPost
|
||||
from posts import getPersonBox
|
||||
from posts import getPublicPostsOfPerson
|
||||
from session import createSession
|
||||
from session import getJson
|
||||
|
|
32
inbox.py
32
inbox.py
|
@ -14,11 +14,39 @@ import json
|
|||
import commentjson
|
||||
from utils import urlPermitted
|
||||
from utils import createInboxQueueDir
|
||||
from posts import getPersonPubKey
|
||||
from httpsig import verifyPostHeaders
|
||||
from session import createSession
|
||||
from session import getJson
|
||||
from follow import receiveFollowRequest
|
||||
from pprint import pprint
|
||||
from cache import getPersonFromCache
|
||||
|
||||
def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool) -> str:
|
||||
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
|
||||
if not personUrl:
|
||||
return None
|
||||
personUrl=personUrl.replace('#main-key','')
|
||||
personJson = getPersonFromCache(personUrl,personCache)
|
||||
if not personJson:
|
||||
if debug:
|
||||
print('DEBUG: Obtaining public key for '+personUrl)
|
||||
personJson = getJson(session,personUrl,asHeader,None)
|
||||
if not personJson:
|
||||
return None
|
||||
pubKey=None
|
||||
if personJson.get('publicKey'):
|
||||
if personJson['publicKey'].get('publicKeyPem'):
|
||||
pubKey=personJson['publicKey']['publicKeyPem']
|
||||
else:
|
||||
if personJson.get('publicKeyPem'):
|
||||
pubKey=personJson['publicKeyPem']
|
||||
|
||||
if not pubKey:
|
||||
if debug:
|
||||
print('DEBUG: Public key not found for '+personUrl)
|
||||
|
||||
storePersonInCache(personUrl,personJson,personCache)
|
||||
return pubKey
|
||||
|
||||
def inboxMessageHasParams(messageJson: {}) -> bool:
|
||||
"""Checks whether an incoming message contains expected parameters
|
||||
|
@ -123,7 +151,7 @@ def runInboxQueue(baseDir: str,httpPrefix: str,personCache: {},queue: [],domain:
|
|||
with open(queueFilename, 'r') as fp:
|
||||
queueJson=commentjson.load(fp)
|
||||
|
||||
# Try a few times to obtain teh public key
|
||||
# Try a few times to obtain the public key
|
||||
pubKey=None
|
||||
for tries in range(8):
|
||||
keyId=None
|
||||
|
|
28
posts.py
28
posts.py
|
@ -85,6 +85,7 @@ def getPersonBox(session,wfRequest: {},personCache: {},boxName='inbox') -> (str,
|
|||
personUrl = getUserUrl(wfRequest)
|
||||
if not personUrl:
|
||||
return None
|
||||
print('**********personUrl: '+personUrl)
|
||||
personJson = getPersonFromCache(personUrl,personCache)
|
||||
if not personJson:
|
||||
personJson = getJson(session,personUrl,asHeader,None)
|
||||
|
@ -107,33 +108,6 @@ def getPersonBox(session,wfRequest: {},personCache: {},boxName='inbox') -> (str,
|
|||
|
||||
return personJson[boxName],pubKeyId,pubKey,personId
|
||||
|
||||
def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool) -> str:
|
||||
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
|
||||
if not personUrl:
|
||||
return None
|
||||
personUrl=personUrl.replace('#main-key','')
|
||||
personJson = getPersonFromCache(personUrl,personCache)
|
||||
if not personJson:
|
||||
if debug:
|
||||
print('DEBUG: Obtaining public key for '+personUrl)
|
||||
personJson = getJson(session,personUrl,asHeader,None)
|
||||
if not personJson:
|
||||
return None
|
||||
pubKey=None
|
||||
if personJson.get('publicKey'):
|
||||
if personJson['publicKey'].get('publicKeyPem'):
|
||||
pubKey=personJson['publicKey']['publicKeyPem']
|
||||
else:
|
||||
if personJson.get('publicKeyPem'):
|
||||
pubKey=personJson['publicKeyPem']
|
||||
|
||||
if not pubKey:
|
||||
if debug:
|
||||
print('DEBUG: Public key not found for '+personUrl)
|
||||
|
||||
storePersonInCache(personUrl,personJson,personCache)
|
||||
return pubKey
|
||||
|
||||
def getPosts(session,outboxUrl: str,maxPosts: int,maxMentions: int, \
|
||||
maxEmoji: int,maxAttachments: int,federationList: [], \
|
||||
personCache: {},raw: bool,simple: bool) -> {}:
|
||||
|
|
Loading…
Reference in New Issue