forked from indymedia/epicyon
Remove capabilities
parent
b064d6f4d6
commit
6435156179
|
@ -27,7 +27,7 @@ def createAcceptReject(baseDir: str, federationList: [],
|
||||||
if not objectJson.get('actor'):
|
if not objectJson.get('actor'):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not urlPermitted(objectJson['actor'], federationList, "inbox:write"):
|
if not urlPermitted(objectJson['actor'], federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if port:
|
if port:
|
||||||
|
@ -52,8 +52,7 @@ def createAcceptReject(baseDir: str, federationList: [],
|
||||||
def createAccept(baseDir: str, federationList: [],
|
def createAccept(baseDir: str, federationList: [],
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
toUrl: str, ccUrl: str, httpPrefix: str,
|
toUrl: str, ccUrl: str, httpPrefix: str,
|
||||||
objectJson: {},
|
objectJson: {}) -> {}:
|
||||||
acceptedCaps=["inbox:write", "objects:read"]) -> {}:
|
|
||||||
return createAcceptReject(baseDir, federationList,
|
return createAcceptReject(baseDir, federationList,
|
||||||
nickname, domain, port,
|
nickname, domain, port,
|
||||||
toUrl, ccUrl, httpPrefix,
|
toUrl, ccUrl, httpPrefix,
|
||||||
|
|
19
announce.py
19
announce.py
|
@ -108,7 +108,7 @@ def createAnnounce(session, baseDir: str, federationList: [],
|
||||||
followers url objectUrl is typically the url of the message,
|
followers url objectUrl is typically the url of the message,
|
||||||
corresponding to url or atomUri in createPostBase
|
corresponding to url or atomUri in createPostBase
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
|
@ -231,7 +231,7 @@ def undoAnnounce(session, baseDir: str, federationList: [],
|
||||||
objectUrl is typically the url of the message which was repeated,
|
objectUrl is typically the url of the message which was repeated,
|
||||||
corresponding to url or atomUri in createPostBase
|
corresponding to url or atomUri in createPostBase
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
|
@ -391,12 +391,12 @@ def sendAnnounceViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey, fromPersonId,
|
(inboxUrl, pubKeyId, pubKey, fromPersonId,
|
||||||
sharedInbox, capabilityAcquisition,
|
sharedInbox, avatarUrl,
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
fromNickname, fromDomain,
|
fromNickname, fromDomain,
|
||||||
postToBox)
|
postToBox)
|
||||||
|
|
||||||
if not inboxUrl:
|
if not inboxUrl:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -414,8 +414,7 @@ def sendAnnounceViaServer(baseDir: str, session,
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newAnnounceJson, [], inboxUrl,
|
postResult = postJson(session, newAnnounceJson, [], inboxUrl, headers)
|
||||||
headers, "inbox:write")
|
|
||||||
if not postResult:
|
if not postResult:
|
||||||
print('WARN: Announce not posted')
|
print('WARN: Announce not posted')
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,6 @@ def sendAvailabilityViaServer(baseDir: str, session,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache, projectVersion,
|
personCache, projectVersion,
|
||||||
httpPrefix, nickname,
|
httpPrefix, nickname,
|
||||||
|
@ -146,7 +145,7 @@ def sendAvailabilityViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newAvailabilityJson, [],
|
postResult = postJson(session, newAvailabilityJson, [],
|
||||||
inboxUrl, headers, "inbox:write")
|
inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
print('WARN: failed to post availability')
|
print('WARN: failed to post availability')
|
||||||
|
|
||||||
|
|
14
bookmarks.py
14
bookmarks.py
|
@ -234,7 +234,7 @@ def bookmark(recentPostsCache: {},
|
||||||
'to' might be a specific person (actor) whose post was bookmarked
|
'to' might be a specific person (actor) whose post was bookmarked
|
||||||
object is typically the url of the message which was bookmarked
|
object is typically the url of the message which was bookmarked
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
fullDomain = domain
|
fullDomain = domain
|
||||||
|
@ -330,7 +330,7 @@ def undoBookmark(recentPostsCache: {},
|
||||||
'to' might be a specific person (actor) whose post was bookmarked
|
'to' might be a specific person (actor) whose post was bookmarked
|
||||||
object is typically the url of the message which was bookmarked
|
object is typically the url of the message which was bookmarked
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
fullDomain = domain
|
fullDomain = domain
|
||||||
|
@ -457,8 +457,7 @@ def sendBookmarkViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
@ -480,7 +479,7 @@ def sendBookmarkViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newBookmarkJson, [],
|
postResult = postJson(session, newBookmarkJson, [],
|
||||||
inboxUrl, headers, "inbox:write")
|
inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
@ -539,8 +538,7 @@ def sendUndoBookmarkViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
@ -562,7 +560,7 @@ def sendUndoBookmarkViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newUndoBookmarkJson, [],
|
postResult = postJson(session, newUndoBookmarkJson, [],
|
||||||
inboxUrl, headers, "inbox:write")
|
inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
|
74
daemon.py
74
daemon.py
|
@ -444,7 +444,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'failed to obtain keyId from signature')
|
'failed to obtain keyId from signature')
|
||||||
return False
|
return False
|
||||||
# is the keyId (actor) valid?
|
# is the keyId (actor) valid?
|
||||||
if not urlPermitted(keyId, self.server.federationList, "inbox:read"):
|
if not urlPermitted(keyId, self.server.federationList):
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('Authorized fetch failed: ' + keyId +
|
print('Authorized fetch failed: ' + keyId +
|
||||||
' is not permitted')
|
' is not permitted')
|
||||||
|
@ -4364,7 +4364,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postLog,
|
self.server.postLog,
|
||||||
self.server.cachedWebfingers,
|
self.server.cachedWebfingers,
|
||||||
self.server.personCache,
|
self.server.personCache,
|
||||||
self.server.acceptedCaps,
|
|
||||||
debug,
|
debug,
|
||||||
self.server.projectVersion)
|
self.server.projectVersion)
|
||||||
originPathStrAbsolute = \
|
originPathStrAbsolute = \
|
||||||
|
@ -5233,7 +5232,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.translate,
|
self.server.translate,
|
||||||
self.server.projectVersion,
|
self.server.projectVersion,
|
||||||
baseDir, httpPrefix, True,
|
baseDir, httpPrefix, True,
|
||||||
self.server.ocapAlways,
|
|
||||||
getPerson, 'roles',
|
getPerson, 'roles',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
|
@ -5304,7 +5302,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.translate,
|
self.server.translate,
|
||||||
self.server.projectVersion,
|
self.server.projectVersion,
|
||||||
baseDir, httpPrefix, True,
|
baseDir, httpPrefix, True,
|
||||||
self.server.ocapAlways,
|
|
||||||
getPerson, 'skills',
|
getPerson, 'skills',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
cachedWebfingers,
|
cachedWebfingers,
|
||||||
|
@ -5571,7 +5568,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
proxyType: str, cookie: str,
|
proxyType: str, cookie: str,
|
||||||
debug: str,
|
debug: str,
|
||||||
recentPostsCache: {}, session,
|
recentPostsCache: {}, session,
|
||||||
ocapAlways: bool,
|
|
||||||
defaultTimeline: str,
|
defaultTimeline: str,
|
||||||
maxRecentPosts: int,
|
maxRecentPosts: int,
|
||||||
translate: {},
|
translate: {},
|
||||||
|
@ -5593,8 +5589,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'inbox',
|
maxPostsInFeed, 'inbox',
|
||||||
authorized,
|
authorized)
|
||||||
ocapAlways)
|
|
||||||
if inboxFeed:
|
if inboxFeed:
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
'show status done',
|
'show status done',
|
||||||
|
@ -5621,8 +5616,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'inbox',
|
maxPostsInFeed, 'inbox',
|
||||||
authorized,
|
authorized)
|
||||||
ocapAlways)
|
|
||||||
self._benchmarkGETtimings(GETstartTime,
|
self._benchmarkGETtimings(GETstartTime,
|
||||||
GETtimings,
|
GETtimings,
|
||||||
'show status done',
|
'show status done',
|
||||||
|
@ -5702,8 +5696,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'dm',
|
maxPostsInFeed, 'dm',
|
||||||
authorized,
|
authorized)
|
||||||
self.server.ocapAlways)
|
|
||||||
if inboxDMFeed:
|
if inboxDMFeed:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
nickname = path.replace('/users/', '')
|
nickname = path.replace('/users/', '')
|
||||||
|
@ -5727,8 +5720,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'dm',
|
maxPostsInFeed, 'dm',
|
||||||
authorized,
|
authorized)
|
||||||
self.server.ocapAlways)
|
|
||||||
msg = \
|
msg = \
|
||||||
htmlInboxDMs(self.server.defaultTimeline,
|
htmlInboxDMs(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -5803,7 +5795,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'tlreplies',
|
maxPostsInFeed, 'tlreplies',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
if not inboxRepliesFeed:
|
if not inboxRepliesFeed:
|
||||||
inboxRepliesFeed = []
|
inboxRepliesFeed = []
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
|
@ -5828,7 +5820,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'tlreplies',
|
maxPostsInFeed, 'tlreplies',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
msg = \
|
msg = \
|
||||||
htmlInboxReplies(self.server.defaultTimeline,
|
htmlInboxReplies(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -5903,7 +5895,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInMediaFeed, 'tlmedia',
|
maxPostsInMediaFeed, 'tlmedia',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
if not inboxMediaFeed:
|
if not inboxMediaFeed:
|
||||||
inboxMediaFeed = []
|
inboxMediaFeed = []
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
|
@ -5928,7 +5920,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInMediaFeed, 'tlmedia',
|
maxPostsInMediaFeed, 'tlmedia',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
msg = \
|
msg = \
|
||||||
htmlInboxMedia(self.server.defaultTimeline,
|
htmlInboxMedia(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -6003,7 +5995,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInBlogsFeed, 'tlblogs',
|
maxPostsInBlogsFeed, 'tlblogs',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
if not inboxBlogsFeed:
|
if not inboxBlogsFeed:
|
||||||
inboxBlogsFeed = []
|
inboxBlogsFeed = []
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
|
@ -6028,7 +6020,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInBlogsFeed, 'tlblogs',
|
maxPostsInBlogsFeed, 'tlblogs',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
msg = \
|
msg = \
|
||||||
htmlInboxBlogs(self.server.defaultTimeline,
|
htmlInboxBlogs(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -6161,7 +6153,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'tlbookmarks',
|
maxPostsInFeed, 'tlbookmarks',
|
||||||
authorized, self.server.ocapAlways)
|
authorized)
|
||||||
if bookmarksFeed:
|
if bookmarksFeed:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
nickname = path.replace('/users/', '')
|
nickname = path.replace('/users/', '')
|
||||||
|
@ -6187,8 +6179,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed,
|
maxPostsInFeed,
|
||||||
'tlbookmarks',
|
'tlbookmarks',
|
||||||
authorized,
|
authorized)
|
||||||
self.server.ocapAlways)
|
|
||||||
msg = \
|
msg = \
|
||||||
htmlBookmarks(self.server.defaultTimeline,
|
htmlBookmarks(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -6265,7 +6256,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'tlevents',
|
maxPostsInFeed, 'tlevents',
|
||||||
authorized, self.server.ocapAlways)
|
authorized)
|
||||||
print('eventsFeed: ' + str(eventsFeed))
|
print('eventsFeed: ' + str(eventsFeed))
|
||||||
if eventsFeed:
|
if eventsFeed:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
|
@ -6291,8 +6282,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed,
|
maxPostsInFeed,
|
||||||
'tlevents',
|
'tlevents',
|
||||||
authorized,
|
authorized)
|
||||||
self.server.ocapAlways)
|
|
||||||
msg = \
|
msg = \
|
||||||
htmlEvents(self.server.defaultTimeline,
|
htmlEvents(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -6361,8 +6351,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
port, path,
|
port, path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'outbox',
|
maxPostsInFeed, 'outbox',
|
||||||
authorized,
|
authorized)
|
||||||
self.server.ocapAlways)
|
|
||||||
if outboxFeed:
|
if outboxFeed:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
nickname = \
|
nickname = \
|
||||||
|
@ -6386,8 +6375,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'outbox',
|
maxPostsInFeed, 'outbox',
|
||||||
authorized,
|
authorized)
|
||||||
self.server.ocapAlways)
|
|
||||||
msg = \
|
msg = \
|
||||||
htmlOutbox(self.server.defaultTimeline,
|
htmlOutbox(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -6449,7 +6437,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path,
|
path,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'moderation',
|
maxPostsInFeed, 'moderation',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
if moderationFeed:
|
if moderationFeed:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
nickname = path.replace('/users/', '')
|
nickname = path.replace('/users/', '')
|
||||||
|
@ -6473,7 +6461,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path + '?page=1',
|
path + '?page=1',
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
maxPostsInFeed, 'moderation',
|
maxPostsInFeed, 'moderation',
|
||||||
True, self.server.ocapAlways)
|
True)
|
||||||
msg = \
|
msg = \
|
||||||
htmlModeration(self.server.defaultTimeline,
|
htmlModeration(self.server.defaultTimeline,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
|
@ -6576,7 +6564,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.projectVersion,
|
self.server.projectVersion,
|
||||||
baseDir, httpPrefix,
|
baseDir, httpPrefix,
|
||||||
authorized,
|
authorized,
|
||||||
self.server.ocapAlways,
|
|
||||||
getPerson, 'shares',
|
getPerson, 'shares',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
self.server.cachedWebfingers,
|
self.server.cachedWebfingers,
|
||||||
|
@ -6663,7 +6650,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.projectVersion,
|
self.server.projectVersion,
|
||||||
baseDir, httpPrefix,
|
baseDir, httpPrefix,
|
||||||
authorized,
|
authorized,
|
||||||
self.server.ocapAlways,
|
|
||||||
getPerson, 'following',
|
getPerson, 'following',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
self.server.cachedWebfingers,
|
self.server.cachedWebfingers,
|
||||||
|
@ -6750,7 +6736,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
baseDir,
|
baseDir,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
authorized,
|
authorized,
|
||||||
self.server.ocapAlways,
|
|
||||||
getPerson, 'followers',
|
getPerson, 'followers',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
self.server.cachedWebfingers,
|
self.server.cachedWebfingers,
|
||||||
|
@ -6812,7 +6797,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
baseDir,
|
baseDir,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
authorized,
|
authorized,
|
||||||
self.server.ocapAlways,
|
|
||||||
getPerson, 'posts',
|
getPerson, 'posts',
|
||||||
self.server.session,
|
self.server.session,
|
||||||
self.server.cachedWebfingers,
|
self.server.cachedWebfingers,
|
||||||
|
@ -8740,7 +8724,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
cookie, self.server.debug,
|
cookie, self.server.debug,
|
||||||
self.server.recentPostsCache,
|
self.server.recentPostsCache,
|
||||||
self.server.session,
|
self.server.session,
|
||||||
self.server.ocapAlways,
|
|
||||||
self.server.defaultTimeline,
|
self.server.defaultTimeline,
|
||||||
self.server.maxRecentPosts,
|
self.server.maxRecentPosts,
|
||||||
self.server.translate,
|
self.server.translate,
|
||||||
|
@ -10621,7 +10604,7 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
|
||||||
fedList=[], maxMentions=10, maxEmoji=10,
|
fedList=[], maxMentions=10, maxEmoji=10,
|
||||||
authenticatedFetch=False,
|
authenticatedFetch=False,
|
||||||
noreply=False, nolike=False, nopics=False,
|
noreply=False, nolike=False, nopics=False,
|
||||||
noannounce=False, cw=False, ocapAlways=False,
|
noannounce=False, cw=False,
|
||||||
proxyType=None, maxReplies=64,
|
proxyType=None, maxReplies=64,
|
||||||
domainMaxPostsPerDay=8640, accountMaxPostsPerDay=864,
|
domainMaxPostsPerDay=8640, accountMaxPostsPerDay=864,
|
||||||
allowDeletion=False, debug=False, unitTest=False,
|
allowDeletion=False, debug=False, unitTest=False,
|
||||||
|
@ -10753,7 +10736,6 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
|
||||||
httpd.sendThreads = sendThreads
|
httpd.sendThreads = sendThreads
|
||||||
httpd.postLog = []
|
httpd.postLog = []
|
||||||
httpd.maxQueueLength = 64
|
httpd.maxQueueLength = 64
|
||||||
httpd.ocapAlways = ocapAlways
|
|
||||||
httpd.allowDeletion = allowDeletion
|
httpd.allowDeletion = allowDeletion
|
||||||
httpd.lastLoginTime = 0
|
httpd.lastLoginTime = 0
|
||||||
httpd.maxReplies = maxReplies
|
httpd.maxReplies = maxReplies
|
||||||
|
@ -10761,19 +10743,8 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
|
||||||
httpd.tokensLookup = {}
|
httpd.tokensLookup = {}
|
||||||
loadTokens(baseDir, httpd.tokens, httpd.tokensLookup)
|
loadTokens(baseDir, httpd.tokens, httpd.tokensLookup)
|
||||||
httpd.instanceOnlySkillsSearch = instanceOnlySkillsSearch
|
httpd.instanceOnlySkillsSearch = instanceOnlySkillsSearch
|
||||||
httpd.acceptedCaps = ["inbox:write", "objects:read"]
|
|
||||||
# contains threads used to send posts to followers
|
# contains threads used to send posts to followers
|
||||||
httpd.followersThreads = []
|
httpd.followersThreads = []
|
||||||
if noreply:
|
|
||||||
httpd.acceptedCaps.append('inbox:noreply')
|
|
||||||
if nolike:
|
|
||||||
httpd.acceptedCaps.append('inbox:nolike')
|
|
||||||
if nopics:
|
|
||||||
httpd.acceptedCaps.append('inbox:nopics')
|
|
||||||
if noannounce:
|
|
||||||
httpd.acceptedCaps.append('inbox:noannounce')
|
|
||||||
if cw:
|
|
||||||
httpd.acceptedCaps.append('inbox:cw')
|
|
||||||
|
|
||||||
if not os.path.isdir(baseDir + '/accounts/inbox@' + domain):
|
if not os.path.isdir(baseDir + '/accounts/inbox@' + domain):
|
||||||
print('Creating shared inbox: inbox@' + domain)
|
print('Creating shared inbox: inbox@' + domain)
|
||||||
|
@ -10844,12 +10815,11 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
|
||||||
httpd.personCache, httpd.inboxQueue,
|
httpd.personCache, httpd.inboxQueue,
|
||||||
domain, onionDomain, i2pDomain, port, proxyType,
|
domain, onionDomain, i2pDomain, port, proxyType,
|
||||||
httpd.federationList,
|
httpd.federationList,
|
||||||
httpd.ocapAlways, maxReplies,
|
maxReplies,
|
||||||
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
||||||
allowDeletion, debug, maxMentions, maxEmoji,
|
allowDeletion, debug, maxMentions, maxEmoji,
|
||||||
httpd.translate, unitTest,
|
httpd.translate, unitTest,
|
||||||
httpd.YTReplacementDomain,
|
httpd.YTReplacementDomain), daemon=True)
|
||||||
httpd.acceptedCaps), daemon=True)
|
|
||||||
print('Creating scheduled post thread')
|
print('Creating scheduled post thread')
|
||||||
httpd.thrPostSchedule = \
|
httpd.thrPostSchedule = \
|
||||||
threadWithTrace(target=runPostSchedule,
|
threadWithTrace(target=runPostSchedule,
|
||||||
|
|
|
@ -34,7 +34,7 @@ def createDelete(session, baseDir: str, federationList: [],
|
||||||
objectUrl is typically the url of the message, corresponding to url
|
objectUrl is typically the url of the message, corresponding to url
|
||||||
or atomUri in createPostBase
|
or atomUri in createPostBase
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
|
@ -137,8 +137,7 @@ def sendDeleteViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
@ -160,7 +159,7 @@ def sendDeleteViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, newDeleteJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, newDeleteJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
|
|
@ -788,7 +788,6 @@ if args.approve:
|
||||||
postLog = []
|
postLog = []
|
||||||
cachedWebfingers = {}
|
cachedWebfingers = {}
|
||||||
personCache = {}
|
personCache = {}
|
||||||
acceptedCaps = []
|
|
||||||
manualApproveFollowRequest(session, baseDir,
|
manualApproveFollowRequest(session, baseDir,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
args.nickname, domain, port,
|
args.nickname, domain, port,
|
||||||
|
@ -796,7 +795,6 @@ if args.approve:
|
||||||
federationList,
|
federationList,
|
||||||
sendThreads, postLog,
|
sendThreads, postLog,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
acceptedCaps,
|
|
||||||
debug, __version__)
|
debug, __version__)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
@ -1181,9 +1179,6 @@ if args.port:
|
||||||
if args.proxyPort:
|
if args.proxyPort:
|
||||||
proxyPort = args.proxyPort
|
proxyPort = args.proxyPort
|
||||||
setConfigParam(baseDir, 'proxyPort', proxyPort)
|
setConfigParam(baseDir, 'proxyPort', proxyPort)
|
||||||
ocapAlways = False
|
|
||||||
if args.ocap:
|
|
||||||
ocapAlways = args.ocap
|
|
||||||
if args.gnunet:
|
if args.gnunet:
|
||||||
httpPrefix = 'gnunet'
|
httpPrefix = 'gnunet'
|
||||||
if args.dat:
|
if args.dat:
|
||||||
|
@ -1901,7 +1896,7 @@ if __name__ == "__main__":
|
||||||
federationList, args.maxMentions,
|
federationList, args.maxMentions,
|
||||||
args.maxEmoji, args.authenticatedFetch,
|
args.maxEmoji, args.authenticatedFetch,
|
||||||
False, False, False,
|
False, False, False,
|
||||||
False, False, ocapAlways,
|
False, False,
|
||||||
proxyType, args.maxReplies,
|
proxyType, args.maxReplies,
|
||||||
args.domainMaxPostsPerDay,
|
args.domainMaxPostsPerDay,
|
||||||
args.accountMaxPostsPerDay,
|
args.accountMaxPostsPerDay,
|
||||||
|
|
27
follow.py
27
follow.py
|
@ -513,8 +513,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
port: int, sendThreads: [], postLog: [],
|
port: int, sendThreads: [], postLog: [],
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
messageJson: {}, federationList: [],
|
messageJson: {}, federationList: [],
|
||||||
debug: bool, projectVersion: str,
|
debug: bool, projectVersion: str) -> bool:
|
||||||
acceptedCaps=["inbox:write", "objects:read"]) -> bool:
|
|
||||||
"""Receives a follow request within the POST section of HTTPServer
|
"""Receives a follow request within the POST section of HTTPServer
|
||||||
"""
|
"""
|
||||||
if not messageJson['type'].startswith('Follow'):
|
if not messageJson['type'].startswith('Follow'):
|
||||||
|
@ -655,8 +654,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
nicknameToFollow, domainToFollow, port,
|
nicknameToFollow, domainToFollow, port,
|
||||||
nickname, domain, fromPort,
|
nickname, domain, fromPort,
|
||||||
messageJson['actor'], federationList,
|
messageJson['actor'], federationList,
|
||||||
messageJson, acceptedCaps,
|
messageJson, sendThreads, postLog,
|
||||||
sendThreads, postLog,
|
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
debug, projectVersion, True)
|
debug, projectVersion, True)
|
||||||
|
|
||||||
|
@ -666,8 +664,7 @@ def followedAccountAccepts(session, baseDir: str, httpPrefix: str,
|
||||||
port: int,
|
port: int,
|
||||||
nickname: str, domain: str, fromPort: int,
|
nickname: str, domain: str, fromPort: int,
|
||||||
personUrl: str, federationList: [],
|
personUrl: str, federationList: [],
|
||||||
followJson: {}, acceptedCaps: [],
|
followJson: {}, sendThreads: [], postLog: [],
|
||||||
sendThreads: [], postLog: [],
|
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool, projectVersion: str,
|
debug: bool, projectVersion: str,
|
||||||
removeFollowActivity: bool):
|
removeFollowActivity: bool):
|
||||||
|
@ -685,7 +682,7 @@ def followedAccountAccepts(session, baseDir: str, httpPrefix: str,
|
||||||
acceptJson = createAccept(baseDir, federationList,
|
acceptJson = createAccept(baseDir, federationList,
|
||||||
nicknameToFollow, domainToFollow, port,
|
nicknameToFollow, domainToFollow, port,
|
||||||
personUrl, '', httpPrefix,
|
personUrl, '', httpPrefix,
|
||||||
followJson, acceptedCaps)
|
followJson)
|
||||||
if debug:
|
if debug:
|
||||||
pprint(acceptJson)
|
pprint(acceptJson)
|
||||||
print('DEBUG: sending follow Accept from ' +
|
print('DEBUG: sending follow Accept from ' +
|
||||||
|
@ -908,8 +905,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
@ -931,7 +927,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, newFollowJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, newFollowJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
@ -1007,10 +1003,11 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition, avatarUrl,
|
avatarUrl, displayName) = getPersonBox(baseDir, session,
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
wfRequest, personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix,
|
||||||
fromDomain, postToBox)
|
fromNickname,
|
||||||
|
fromDomain, postToBox)
|
||||||
|
|
||||||
if not inboxUrl:
|
if not inboxUrl:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1029,7 +1026,7 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, unfollowJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, unfollowJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
|
36
inbox.py
36
inbox.py
|
@ -265,7 +265,7 @@ def inboxPermittedMessage(domain: str, messageJson: {},
|
||||||
if domain in actor:
|
if domain in actor:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not urlPermitted(actor, federationList, "inbox:write"):
|
if not urlPermitted(actor, federationList):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
alwaysAllowedTypes = ('Follow', 'Like', 'Delete', 'Announce')
|
alwaysAllowedTypes = ('Follow', 'Like', 'Delete', 'Announce')
|
||||||
|
@ -278,7 +278,7 @@ def inboxPermittedMessage(domain: str, messageJson: {},
|
||||||
inReplyTo = messageJson['object']['inReplyTo']
|
inReplyTo = messageJson['object']['inReplyTo']
|
||||||
if not isinstance(inReplyTo, str):
|
if not isinstance(inReplyTo, str):
|
||||||
return False
|
return False
|
||||||
if not urlPermitted(inReplyTo, federationList, "inbox:write"):
|
if not urlPermitted(inReplyTo, federationList):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -652,8 +652,7 @@ def receiveUndo(session, baseDir: str, httpPrefix: str,
|
||||||
port: int, sendThreads: [], postLog: [],
|
port: int, sendThreads: [], postLog: [],
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
messageJson: {}, federationList: [],
|
messageJson: {}, federationList: [],
|
||||||
debug: bool,
|
debug: bool) -> bool:
|
||||||
acceptedCaps=["inbox:write", "objects:read"]) -> bool:
|
|
||||||
"""Receives an undo request within the POST section of HTTPServer
|
"""Receives an undo request within the POST section of HTTPServer
|
||||||
"""
|
"""
|
||||||
if not messageJson['type'].startswith('Undo'):
|
if not messageJson['type'].startswith('Undo'):
|
||||||
|
@ -2024,8 +2023,7 @@ def inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
queue: [], domain: str,
|
queue: [], domain: str,
|
||||||
onionDomain: str, i2pDomain: str,
|
onionDomain: str, i2pDomain: str,
|
||||||
port: int, proxyType: str,
|
port: int, proxyType: str,
|
||||||
federationList: [], ocapAlways: bool, debug: bool,
|
federationList: [], debug: bool,
|
||||||
acceptedCaps: [],
|
|
||||||
queueFilename: str, destinationFilename: str,
|
queueFilename: str, destinationFilename: str,
|
||||||
maxReplies: int, allowDeletion: bool,
|
maxReplies: int, allowDeletion: bool,
|
||||||
maxMentions: int, maxEmoji: int, translate: {},
|
maxMentions: int, maxEmoji: int, translate: {},
|
||||||
|
@ -2419,13 +2417,11 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
cachedWebfingers: {}, personCache: {}, queue: [],
|
cachedWebfingers: {}, personCache: {}, queue: [],
|
||||||
domain: str,
|
domain: str,
|
||||||
onionDomain: str, i2pDomain: str, port: int, proxyType: str,
|
onionDomain: str, i2pDomain: str, port: int, proxyType: str,
|
||||||
federationList: [],
|
federationList: [], maxReplies: int,
|
||||||
ocapAlways: bool, maxReplies: int,
|
|
||||||
domainMaxPostsPerDay: int, accountMaxPostsPerDay: int,
|
domainMaxPostsPerDay: int, accountMaxPostsPerDay: int,
|
||||||
allowDeletion: bool, debug: bool, maxMentions: int,
|
allowDeletion: bool, debug: bool, maxMentions: int,
|
||||||
maxEmoji: int, translate: {}, unitTest: bool,
|
maxEmoji: int, translate: {}, unitTest: bool,
|
||||||
YTReplacementDomain: str,
|
YTReplacementDomain: str) -> None:
|
||||||
acceptedCaps=["inbox:write", "objects:read"]) -> None:
|
|
||||||
"""Processes received items and moves them to the appropriate
|
"""Processes received items and moves them to the appropriate
|
||||||
directories
|
directories
|
||||||
"""
|
"""
|
||||||
|
@ -2694,8 +2690,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
personCache,
|
personCache,
|
||||||
queueJson['post'],
|
queueJson['post'],
|
||||||
federationList,
|
federationList,
|
||||||
debug,
|
debug):
|
||||||
acceptedCaps=["inbox:write", "objects:read"]):
|
|
||||||
print('Queue: Undo accepted from ' + keyId)
|
print('Queue: Undo accepted from ' + keyId)
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
@ -2712,9 +2707,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
personCache,
|
personCache,
|
||||||
queueJson['post'],
|
queueJson['post'],
|
||||||
federationList,
|
federationList,
|
||||||
debug, projectVersion,
|
debug, projectVersion):
|
||||||
acceptedCaps=["inbox:write",
|
|
||||||
"objects:read"]):
|
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
|
@ -2810,15 +2803,6 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
pprint(recipientsDictFollowers)
|
pprint(recipientsDictFollowers)
|
||||||
print('*************************************')
|
print('*************************************')
|
||||||
|
|
||||||
if queueJson['post'].get('capability'):
|
|
||||||
if not isinstance(queueJson['post']['capability'], list):
|
|
||||||
print('Queue: capability on post should be a list')
|
|
||||||
if os.path.isfile(queueFilename):
|
|
||||||
os.remove(queueFilename)
|
|
||||||
if len(queue) > 0:
|
|
||||||
queue.pop(0)
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Copy any posts addressed to followers into the shared inbox
|
# Copy any posts addressed to followers into the shared inbox
|
||||||
# this avoid copying file multiple times to potentially many
|
# this avoid copying file multiple times to potentially many
|
||||||
# individual inboxes
|
# individual inboxes
|
||||||
|
@ -2843,8 +2827,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
domain,
|
domain,
|
||||||
onionDomain, i2pDomain,
|
onionDomain, i2pDomain,
|
||||||
port, proxyType,
|
port, proxyType,
|
||||||
federationList, ocapAlways,
|
federationList,
|
||||||
debug, acceptedCaps,
|
debug,
|
||||||
queueFilename, destination,
|
queueFilename, destination,
|
||||||
maxReplies, allowDeletion,
|
maxReplies, allowDeletion,
|
||||||
maxMentions, maxEmoji,
|
maxMentions, maxEmoji,
|
||||||
|
|
16
like.py
16
like.py
|
@ -63,7 +63,7 @@ def like(recentPostsCache: {},
|
||||||
'to' might be a specific person (actor) whose post was liked
|
'to' might be a specific person (actor) whose post was liked
|
||||||
object is typically the url of the message which was liked
|
object is typically the url of the message which was liked
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
fullDomain = domain
|
fullDomain = domain
|
||||||
|
@ -162,7 +162,7 @@ def undolike(recentPostsCache: {},
|
||||||
'to' might be a specific person (actor) whose post was liked
|
'to' might be a specific person (actor) whose post was liked
|
||||||
object is typically the url of the message which was liked
|
object is typically the url of the message which was liked
|
||||||
"""
|
"""
|
||||||
if not urlPermitted(objectUrl, federationList, "inbox:write"):
|
if not urlPermitted(objectUrl, federationList):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
fullDomain = domain
|
fullDomain = domain
|
||||||
|
@ -267,8 +267,7 @@ def sendLikeViaServer(baseDir: str, session,
|
||||||
postToBox = 'outbox'
|
postToBox = 'outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey, fromPersonId,
|
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox,
|
||||||
sharedInbox, capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -291,8 +290,7 @@ def sendLikeViaServer(baseDir: str, session,
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newLikeJson, [], inboxUrl,
|
postResult = postJson(session, newLikeJson, [], inboxUrl, headers)
|
||||||
headers, "inbox:write")
|
|
||||||
if not postResult:
|
if not postResult:
|
||||||
print('WARN: POST announce failed for c2s to ' + inboxUrl)
|
print('WARN: POST announce failed for c2s to ' + inboxUrl)
|
||||||
return 5
|
return 5
|
||||||
|
@ -352,8 +350,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
|
||||||
postToBox = 'outbox'
|
postToBox = 'outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey, fromPersonId,
|
(inboxUrl, pubKeyId, pubKey, fromPersonId, sharedInbox,
|
||||||
sharedInbox, capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache, projectVersion,
|
personCache, projectVersion,
|
||||||
httpPrefix, fromNickname,
|
httpPrefix, fromNickname,
|
||||||
|
@ -375,8 +372,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newUndoLikeJson, [], inboxUrl,
|
postResult = postJson(session, newUndoLikeJson, [], inboxUrl, headers)
|
||||||
headers, "inbox:write")
|
|
||||||
if not postResult:
|
if not postResult:
|
||||||
print('WARN: POST announce failed for c2s to ' + inboxUrl)
|
print('WARN: POST announce failed for c2s to ' + inboxUrl)
|
||||||
return 5
|
return 5
|
||||||
|
|
|
@ -85,7 +85,6 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
federationList: [],
|
federationList: [],
|
||||||
sendThreads: [], postLog: [],
|
sendThreads: [], postLog: [],
|
||||||
cachedWebfingers: {}, personCache: {},
|
cachedWebfingers: {}, personCache: {},
|
||||||
acceptedCaps: [],
|
|
||||||
debug: bool,
|
debug: bool,
|
||||||
projectVersion: str) -> None:
|
projectVersion: str) -> None:
|
||||||
"""Manually approve a follow request
|
"""Manually approve a follow request
|
||||||
|
@ -142,7 +141,7 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
approvePort,
|
approvePort,
|
||||||
followJson['actor'],
|
followJson['actor'],
|
||||||
federationList,
|
federationList,
|
||||||
followJson, acceptedCaps,
|
followJson,
|
||||||
sendThreads, postLog,
|
sendThreads, postLog,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers, personCache,
|
||||||
debug, projectVersion, False)
|
debug, projectVersion, False)
|
||||||
|
|
24
person.py
24
person.py
|
@ -326,8 +326,6 @@ def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if not os.path.isdir(baseDir + peopleSubdir + '/' +
|
if not os.path.isdir(baseDir + peopleSubdir + '/' +
|
||||||
handle + '/outbox'):
|
handle + '/outbox'):
|
||||||
os.mkdir(baseDir + peopleSubdir + '/' + handle + '/outbox')
|
os.mkdir(baseDir + peopleSubdir + '/' + handle + '/outbox')
|
||||||
if not os.path.isdir(baseDir + peopleSubdir + '/' + handle + '/ocap'):
|
|
||||||
os.mkdir(baseDir + peopleSubdir + '/' + handle + '/ocap')
|
|
||||||
if not os.path.isdir(baseDir + peopleSubdir + '/' + handle + '/queue'):
|
if not os.path.isdir(baseDir + peopleSubdir + '/' + handle + '/queue'):
|
||||||
os.mkdir(baseDir + peopleSubdir + '/' + handle + '/queue')
|
os.mkdir(baseDir + peopleSubdir + '/' + handle + '/queue')
|
||||||
filename = baseDir + peopleSubdir + '/' + handle + '.json'
|
filename = baseDir + peopleSubdir + '/' + handle + '.json'
|
||||||
|
@ -588,7 +586,7 @@ def personLookup(domain: str, path: str, baseDir: str) -> {}:
|
||||||
def personBoxJson(recentPostsCache: {},
|
def personBoxJson(recentPostsCache: {},
|
||||||
session, baseDir: str, domain: str, port: int, path: str,
|
session, baseDir: str, domain: str, port: int, path: str,
|
||||||
httpPrefix: str, noOfItems: int, boxname: str,
|
httpPrefix: str, noOfItems: int, boxname: str,
|
||||||
authorized: bool, ocapAlways: bool) -> {}:
|
authorized: bool) -> {}:
|
||||||
"""Obtain the inbox/outbox/moderation feed for the given person
|
"""Obtain the inbox/outbox/moderation feed for the given person
|
||||||
"""
|
"""
|
||||||
if boxname != 'inbox' and boxname != 'dm' and \
|
if boxname != 'inbox' and boxname != 'dm' and \
|
||||||
|
@ -634,38 +632,36 @@ def personBoxJson(recentPostsCache: {},
|
||||||
return createInbox(recentPostsCache,
|
return createInbox(recentPostsCache,
|
||||||
session, baseDir, nickname, domain, port,
|
session, baseDir, nickname, domain, port,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
noOfItems, headerOnly, ocapAlways, pageNumber)
|
noOfItems, headerOnly, pageNumber)
|
||||||
elif boxname == 'dm':
|
elif boxname == 'dm':
|
||||||
return createDMTimeline(recentPostsCache,
|
return createDMTimeline(recentPostsCache,
|
||||||
session, baseDir, nickname, domain, port,
|
session, baseDir, nickname, domain, port,
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
noOfItems, headerOnly, ocapAlways, pageNumber)
|
noOfItems, headerOnly, pageNumber)
|
||||||
elif boxname == 'tlbookmarks' or boxname == 'bookmarks':
|
elif boxname == 'tlbookmarks' or boxname == 'bookmarks':
|
||||||
return createBookmarksTimeline(session, baseDir, nickname, domain,
|
return createBookmarksTimeline(session, baseDir, nickname, domain,
|
||||||
port, httpPrefix,
|
port, httpPrefix,
|
||||||
noOfItems, headerOnly, ocapAlways,
|
noOfItems, headerOnly,
|
||||||
pageNumber)
|
pageNumber)
|
||||||
elif boxname == 'tlevents':
|
elif boxname == 'tlevents':
|
||||||
return createEventsTimeline(recentPostsCache,
|
return createEventsTimeline(recentPostsCache,
|
||||||
session, baseDir, nickname, domain,
|
session, baseDir, nickname, domain,
|
||||||
port, httpPrefix,
|
port, httpPrefix,
|
||||||
noOfItems, headerOnly, ocapAlways,
|
noOfItems, headerOnly,
|
||||||
pageNumber)
|
pageNumber)
|
||||||
elif boxname == 'tlreplies':
|
elif boxname == 'tlreplies':
|
||||||
return createRepliesTimeline(recentPostsCache,
|
return createRepliesTimeline(recentPostsCache,
|
||||||
session, baseDir, nickname, domain,
|
session, baseDir, nickname, domain,
|
||||||
port, httpPrefix,
|
port, httpPrefix,
|
||||||
noOfItems, headerOnly, ocapAlways,
|
noOfItems, headerOnly,
|
||||||
pageNumber)
|
pageNumber)
|
||||||
elif boxname == 'tlmedia':
|
elif boxname == 'tlmedia':
|
||||||
return createMediaTimeline(session, baseDir, nickname, domain, port,
|
return createMediaTimeline(session, baseDir, nickname, domain, port,
|
||||||
httpPrefix,
|
httpPrefix, noOfItems, headerOnly,
|
||||||
noOfItems, headerOnly, ocapAlways,
|
|
||||||
pageNumber)
|
pageNumber)
|
||||||
elif boxname == 'tlblogs':
|
elif boxname == 'tlblogs':
|
||||||
return createBlogsTimeline(session, baseDir, nickname, domain, port,
|
return createBlogsTimeline(session, baseDir, nickname, domain, port,
|
||||||
httpPrefix,
|
httpPrefix, noOfItems, headerOnly,
|
||||||
noOfItems, headerOnly, ocapAlways,
|
|
||||||
pageNumber)
|
pageNumber)
|
||||||
elif boxname == 'outbox':
|
elif boxname == 'outbox':
|
||||||
return createOutbox(session, baseDir, nickname, domain, port,
|
return createOutbox(session, baseDir, nickname, domain, port,
|
||||||
|
@ -682,7 +678,7 @@ def personBoxJson(recentPostsCache: {},
|
||||||
|
|
||||||
def personInboxJson(recentPostsCache: {},
|
def personInboxJson(recentPostsCache: {},
|
||||||
baseDir: str, domain: str, port: int, path: str,
|
baseDir: str, domain: str, port: int, path: str,
|
||||||
httpPrefix: str, noOfItems: int, ocapAlways: bool) -> []:
|
httpPrefix: str, noOfItems: int) -> []:
|
||||||
"""Obtain the inbox feed for the given person
|
"""Obtain the inbox feed for the given person
|
||||||
Authentication is expected to have already happened
|
Authentication is expected to have already happened
|
||||||
"""
|
"""
|
||||||
|
@ -719,7 +715,7 @@ def personInboxJson(recentPostsCache: {},
|
||||||
return None
|
return None
|
||||||
return createInbox(recentPostsCache, baseDir, nickname,
|
return createInbox(recentPostsCache, baseDir, nickname,
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
noOfItems, headerOnly, ocapAlways, pageNumber)
|
noOfItems, headerOnly, pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def setDisplayNickname(baseDir: str, nickname: str, domain: str,
|
def setDisplayNickname(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
83
posts.py
83
posts.py
|
@ -208,7 +208,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
else:
|
else:
|
||||||
personUrl = httpPrefix + '://' + domain + '/users/' + nickname
|
personUrl = httpPrefix + '://' + domain + '/users/' + nickname
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
return None, None, None, None, None, None, None, None
|
return None, None, None, None, None, None, None
|
||||||
personJson = \
|
personJson = \
|
||||||
getPersonFromCache(baseDir, personUrl, personCache, True)
|
getPersonFromCache(baseDir, personUrl, personCache, True)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
|
@ -226,7 +226,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
projectVersion, httpPrefix, domain)
|
projectVersion, httpPrefix, domain)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
print('Unable to get actor')
|
print('Unable to get actor')
|
||||||
return None, None, None, None, None, None, None, None
|
return None, None, None, None, None, None, None
|
||||||
boxJson = None
|
boxJson = None
|
||||||
if not personJson.get(boxName):
|
if not personJson.get(boxName):
|
||||||
if personJson.get('endpoints'):
|
if personJson.get('endpoints'):
|
||||||
|
@ -236,7 +236,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
boxJson = personJson[boxName]
|
boxJson = personJson[boxName]
|
||||||
|
|
||||||
if not boxJson:
|
if not boxJson:
|
||||||
return None, None, None, None, None, None, None, None
|
return None, None, None, None, None, None, None
|
||||||
|
|
||||||
personId = None
|
personId = None
|
||||||
if personJson.get('id'):
|
if personJson.get('id'):
|
||||||
|
@ -255,9 +255,6 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
if personJson.get('endpoints'):
|
if personJson.get('endpoints'):
|
||||||
if personJson['endpoints'].get('sharedInbox'):
|
if personJson['endpoints'].get('sharedInbox'):
|
||||||
sharedInbox = personJson['endpoints']['sharedInbox']
|
sharedInbox = personJson['endpoints']['sharedInbox']
|
||||||
capabilityAcquisition = None
|
|
||||||
if personJson.get('capabilityAcquisitionEndpoint'):
|
|
||||||
capabilityAcquisition = personJson['capabilityAcquisitionEndpoint']
|
|
||||||
avatarUrl = None
|
avatarUrl = None
|
||||||
if personJson.get('icon'):
|
if personJson.get('icon'):
|
||||||
if personJson['icon'].get('url'):
|
if personJson['icon'].get('url'):
|
||||||
|
@ -269,7 +266,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
storePersonInCache(baseDir, personUrl, personJson, personCache, True)
|
storePersonInCache(baseDir, personUrl, personJson, personCache, True)
|
||||||
|
|
||||||
return boxJson, pubKeyId, pubKey, personId, sharedInbox, \
|
return boxJson, pubKeyId, pubKey, personId, sharedInbox, \
|
||||||
capabilityAcquisition, avatarUrl, displayName
|
avatarUrl, displayName
|
||||||
|
|
||||||
|
|
||||||
def getPosts(session, outboxUrl: str, maxPosts: int,
|
def getPosts(session, outboxUrl: str, maxPosts: int,
|
||||||
|
@ -1061,11 +1058,9 @@ def outboxMessageCreateWrap(httpPrefix: str,
|
||||||
cc = []
|
cc = []
|
||||||
if messageJson.get('cc'):
|
if messageJson.get('cc'):
|
||||||
cc = messageJson['cc']
|
cc = messageJson['cc']
|
||||||
capabilityUrl = []
|
|
||||||
newPost = {
|
newPost = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'id': newPostId + '/activity',
|
'id': newPostId + '/activity',
|
||||||
'capability': capabilityUrl,
|
|
||||||
'type': 'Create',
|
'type': 'Create',
|
||||||
'actor': httpPrefix + '://' + domain + '/users/' + nickname,
|
'actor': httpPrefix + '://' + domain + '/users/' + nickname,
|
||||||
'published': published,
|
'published': published,
|
||||||
|
@ -1569,7 +1564,7 @@ def threadSendPost(session, postJsonStr: str, federationList: [],
|
||||||
postResult, unauthorized = \
|
postResult, unauthorized = \
|
||||||
postJsonString(session, postJsonStr, federationList,
|
postJsonString(session, postJsonStr, federationList,
|
||||||
inboxUrl, signatureHeaderJson,
|
inboxUrl, signatureHeaderJson,
|
||||||
"inbox:write", debug)
|
debug)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: postJsonString failed ' + str(e))
|
print('ERROR: postJsonString failed ' + str(e))
|
||||||
if unauthorized:
|
if unauthorized:
|
||||||
|
@ -1654,7 +1649,6 @@ def sendPost(projectVersion: str,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
toPersonId, sharedInbox,
|
toPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -1772,7 +1766,6 @@ def sendPostViaServer(projectVersion: str,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -1838,7 +1831,7 @@ def sendPostViaServer(projectVersion: str,
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postImage(session, attachImageFilename, [],
|
postImage(session, attachImageFilename, [],
|
||||||
inboxUrl, headers, "inbox:write")
|
inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Failed to upload image')
|
print('DEBUG: Failed to upload image')
|
||||||
|
@ -1851,7 +1844,7 @@ def sendPostViaServer(projectVersion: str,
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJsonString(session, json.dumps(postJsonObject), [],
|
postJsonString(session, json.dumps(postJsonObject), [],
|
||||||
inboxUrl, headers, "inbox:write", debug)
|
inboxUrl, headers, debug)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST failed for c2s to '+inboxUrl)
|
print('DEBUG: POST failed for c2s to '+inboxUrl)
|
||||||
|
@ -1983,8 +1976,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
||||||
postToBox = 'outbox'
|
postToBox = 'outbox'
|
||||||
|
|
||||||
# get the actor inbox/outbox for the To handle
|
# get the actor inbox/outbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey, toPersonId, sharedInboxUrl,
|
(inboxUrl, pubKeyId, pubKey, toPersonId, sharedInboxUrl, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest,
|
displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -2447,75 +2439,69 @@ def sendToFollowersThread(session, baseDir: str,
|
||||||
def createInbox(recentPostsCache: {},
|
def createInbox(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str, port: int,
|
session, baseDir: str, nickname: str, domain: str, port: int,
|
||||||
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
||||||
ocapAlways: bool, pageNumber=None) -> {}:
|
pageNumber=None) -> {}:
|
||||||
return createBoxIndexed(recentPostsCache,
|
return createBoxIndexed(recentPostsCache,
|
||||||
session, baseDir, 'inbox',
|
session, baseDir, 'inbox',
|
||||||
nickname, domain, port, httpPrefix,
|
nickname, domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
ocapAlways, pageNumber)
|
pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, ocapAlways: bool,
|
headerOnly: bool, pageNumber=None) -> {}:
|
||||||
pageNumber=None) -> {}:
|
|
||||||
return createBoxIndexed({}, session, baseDir, 'tlbookmarks',
|
return createBoxIndexed({}, session, baseDir, 'tlbookmarks',
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
port, httpPrefix, itemsPerPage, headerOnly,
|
port, httpPrefix, itemsPerPage, headerOnly,
|
||||||
True, ocapAlways, pageNumber)
|
True, pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createEventsTimeline(recentPostsCache: {},
|
def createEventsTimeline(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str,
|
session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, ocapAlways: bool,
|
headerOnly: bool, pageNumber=None) -> {}:
|
||||||
pageNumber=None) -> {}:
|
|
||||||
return createBoxIndexed(recentPostsCache, session, baseDir, 'tlevents',
|
return createBoxIndexed(recentPostsCache, session, baseDir, 'tlevents',
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
port, httpPrefix, itemsPerPage, headerOnly,
|
port, httpPrefix, itemsPerPage, headerOnly,
|
||||||
True, ocapAlways, pageNumber)
|
True, pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createDMTimeline(recentPostsCache: {},
|
def createDMTimeline(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str,
|
session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, ocapAlways: bool,
|
headerOnly: bool, pageNumber=None) -> {}:
|
||||||
pageNumber=None) -> {}:
|
|
||||||
return createBoxIndexed(recentPostsCache,
|
return createBoxIndexed(recentPostsCache,
|
||||||
session, baseDir, 'dm', nickname,
|
session, baseDir, 'dm', nickname,
|
||||||
domain, port, httpPrefix, itemsPerPage,
|
domain, port, httpPrefix, itemsPerPage,
|
||||||
headerOnly, True, ocapAlways, pageNumber)
|
headerOnly, True, pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createRepliesTimeline(recentPostsCache: {},
|
def createRepliesTimeline(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str,
|
session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, ocapAlways: bool,
|
headerOnly: bool, pageNumber=None) -> {}:
|
||||||
pageNumber=None) -> {}:
|
|
||||||
return createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies',
|
return createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies',
|
||||||
nickname, domain, port, httpPrefix,
|
nickname, domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
ocapAlways, pageNumber)
|
pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, ocapAlways: bool,
|
headerOnly: bool, pageNumber=None) -> {}:
|
||||||
pageNumber=None) -> {}:
|
|
||||||
return createBoxIndexed({}, session, baseDir, 'tlblogs', nickname,
|
return createBoxIndexed({}, session, baseDir, 'tlblogs', nickname,
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
ocapAlways, pageNumber)
|
pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createMediaTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createMediaTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, ocapAlways: bool,
|
headerOnly: bool, pageNumber=None) -> {}:
|
||||||
pageNumber=None) -> {}:
|
|
||||||
return createBoxIndexed({}, session, baseDir, 'tlmedia', nickname,
|
return createBoxIndexed({}, session, baseDir, 'tlmedia', nickname,
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
ocapAlways, pageNumber)
|
pageNumber)
|
||||||
|
|
||||||
|
|
||||||
def createOutbox(session, baseDir: str, nickname: str, domain: str,
|
def createOutbox(session, baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -2530,7 +2516,7 @@ def createOutbox(session, baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
||||||
ocapAlways: bool, pageNumber=None) -> {}:
|
pageNumber=None) -> {}:
|
||||||
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
|
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
|
||||||
boxname = 'moderation'
|
boxname = 'moderation'
|
||||||
|
|
||||||
|
@ -2728,8 +2714,7 @@ def createBoxIndex(boxDir: str, postsInBoxDict: {}) -> int:
|
||||||
|
|
||||||
def createSharedInboxIndex(baseDir: str, sharedBoxDir: str,
|
def createSharedInboxIndex(baseDir: str, sharedBoxDir: str,
|
||||||
postsInBoxDict: {}, postsCtr: int,
|
postsInBoxDict: {}, postsCtr: int,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str) -> int:
|
||||||
ocapAlways: bool) -> int:
|
|
||||||
""" Creates an index for the given shared inbox
|
""" Creates an index for the given shared inbox
|
||||||
"""
|
"""
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
|
@ -2819,7 +2804,7 @@ def createBoxIndexed(recentPostsCache: {},
|
||||||
session, baseDir: str, boxname: str,
|
session, baseDir: str, boxname: str,
|
||||||
nickname: str, domain: str, port: int, httpPrefix: str,
|
nickname: str, domain: str, port: int, httpPrefix: str,
|
||||||
itemsPerPage: int, headerOnly: bool, authorized: bool,
|
itemsPerPage: int, headerOnly: bool, authorized: bool,
|
||||||
ocapAlways: bool, pageNumber=None) -> {}:
|
pageNumber=None) -> {}:
|
||||||
"""Constructs the box feed for a person with the given nickname
|
"""Constructs the box feed for a person with the given nickname
|
||||||
"""
|
"""
|
||||||
if not authorized or not pageNumber:
|
if not authorized or not pageNumber:
|
||||||
|
@ -2958,10 +2943,6 @@ def createBoxIndexed(recentPostsCache: {},
|
||||||
except BaseException:
|
except BaseException:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# remove any capability so that it's not displayed
|
|
||||||
if p.get('capability'):
|
|
||||||
del p['capability']
|
|
||||||
|
|
||||||
# Don't show likes, replies or shares (announces) to
|
# Don't show likes, replies or shares (announces) to
|
||||||
# unauthorized viewers
|
# unauthorized viewers
|
||||||
if not authorized:
|
if not authorized:
|
||||||
|
@ -3179,7 +3160,6 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
(personUrl, pubKeyId, pubKey,
|
(personUrl, pubKeyId, pubKey,
|
||||||
personId, shaedInbox,
|
personId, shaedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -3225,7 +3205,6 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
(personUrl, pubKeyId, pubKey,
|
(personUrl, pubKeyId, pubKey,
|
||||||
personId, sharedInbox,
|
personId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -3728,8 +3707,7 @@ def sendBlockViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest,
|
displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix, fromNickname,
|
||||||
|
@ -3751,8 +3729,7 @@ def sendBlockViaServer(baseDir: str, session,
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newBlockJson, [], inboxUrl,
|
postResult = postJson(session, newBlockJson, [], inboxUrl, headers)
|
||||||
headers, "inbox:write")
|
|
||||||
if not postResult:
|
if not postResult:
|
||||||
print('WARN: Unable to post block')
|
print('WARN: Unable to post block')
|
||||||
|
|
||||||
|
@ -3817,8 +3794,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox, avatarUrl,
|
||||||
capabilityAcquisition, avatarUrl,
|
|
||||||
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
projectVersion, httpPrefix, fromNickname,
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
@ -3839,8 +3815,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = postJson(session, newBlockJson, [], inboxUrl,
|
postResult = postJson(session, newBlockJson, [], inboxUrl, headers)
|
||||||
headers, "inbox:write")
|
|
||||||
if not postResult:
|
if not postResult:
|
||||||
print('WARN: Unable to post block')
|
print('WARN: Unable to post block')
|
||||||
|
|
||||||
|
|
3
roles.py
3
roles.py
|
@ -291,7 +291,6 @@ def sendRoleViaServer(baseDir: str, session,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session,
|
avatarUrl, displayName) = getPersonBox(baseDir, session,
|
||||||
wfRequest, personCache,
|
wfRequest, personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
@ -315,7 +314,7 @@ def sendRoleViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, newRoleJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, newRoleJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to '+inboxUrl)
|
print('DEBUG: POST announce failed for c2s to '+inboxUrl)
|
||||||
|
|
28
session.py
28
session.py
|
@ -93,16 +93,13 @@ def getJson(session, url: str, headers: {}, params: {},
|
||||||
|
|
||||||
|
|
||||||
def postJson(session, postJsonObject: {}, federationList: [],
|
def postJson(session, postJsonObject: {}, federationList: [],
|
||||||
inboxUrl: str, headers: {}, capability: str) -> str:
|
inboxUrl: str, headers: {}) -> str:
|
||||||
"""Post a json message to the inbox of another person
|
"""Post a json message to the inbox of another person
|
||||||
Supplying a capability, such as "inbox:write"
|
|
||||||
"""
|
"""
|
||||||
# always allow capability requests
|
# check that we are posting to a permitted domain
|
||||||
if not capability.startswith('cap'):
|
if not urlPermitted(inboxUrl, federationList):
|
||||||
# check that we are posting to a permitted domain
|
print('postJson: ' + inboxUrl + ' not permitted')
|
||||||
if not urlPermitted(inboxUrl, federationList, capability):
|
return None
|
||||||
print('postJson: ' + inboxUrl + ' not permitted')
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
postResult = \
|
postResult = \
|
||||||
|
@ -132,10 +129,8 @@ def postJsonString(session, postJsonStr: str,
|
||||||
federationList: [],
|
federationList: [],
|
||||||
inboxUrl: str,
|
inboxUrl: str,
|
||||||
headers: {},
|
headers: {},
|
||||||
capability: str,
|
|
||||||
debug: bool) -> (bool, bool):
|
debug: bool) -> (bool, bool):
|
||||||
"""Post a json message string to the inbox of another person
|
"""Post a json message string to the inbox of another person
|
||||||
Supplying a capability, such as "inbox:write"
|
|
||||||
The second boolean returned is true if the send is unauthorized
|
The second boolean returned is true if the send is unauthorized
|
||||||
NOTE: Here we post a string rather than the original json so that
|
NOTE: Here we post a string rather than the original json so that
|
||||||
conversions between string and json format don't invalidate
|
conversions between string and json format don't invalidate
|
||||||
|
@ -174,16 +169,13 @@ def postJsonString(session, postJsonStr: str,
|
||||||
|
|
||||||
|
|
||||||
def postImage(session, attachImageFilename: str, federationList: [],
|
def postImage(session, attachImageFilename: str, federationList: [],
|
||||||
inboxUrl: str, headers: {}, capability: str) -> str:
|
inboxUrl: str, headers: {}) -> str:
|
||||||
"""Post an image to the inbox of another person or outbox via c2s
|
"""Post an image to the inbox of another person or outbox via c2s
|
||||||
Supplying a capability, such as "inbox:write"
|
|
||||||
"""
|
"""
|
||||||
# always allow capability requests
|
# check that we are posting to a permitted domain
|
||||||
if not capability.startswith('cap'):
|
if not urlPermitted(inboxUrl, federationList):
|
||||||
# check that we are posting to a permitted domain
|
print('postJson: ' + inboxUrl + ' not permitted')
|
||||||
if not urlPermitted(inboxUrl, federationList, capability):
|
return None
|
||||||
print('postJson: ' + inboxUrl + ' not permitted')
|
|
||||||
return None
|
|
||||||
|
|
||||||
if not (attachImageFilename.endswith('.jpg') or
|
if not (attachImageFilename.endswith('.jpg') or
|
||||||
attachImageFilename.endswith('.jpeg') or
|
attachImageFilename.endswith('.jpeg') or
|
||||||
|
|
|
@ -380,7 +380,6 @@ def sendShareViaServer(baseDir, session,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache, projectVersion,
|
personCache, projectVersion,
|
||||||
httpPrefix, fromNickname,
|
httpPrefix, fromNickname,
|
||||||
|
@ -405,7 +404,7 @@ def sendShareViaServer(baseDir, session,
|
||||||
postResult = \
|
postResult = \
|
||||||
postImage(session, imageFilename, [],
|
postImage(session, imageFilename, [],
|
||||||
inboxUrl.replace('/' + postToBox, '/shares'),
|
inboxUrl.replace('/' + postToBox, '/shares'),
|
||||||
headers, "inbox:write")
|
headers)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'host': fromDomain,
|
'host': fromDomain,
|
||||||
|
@ -413,7 +412,7 @@ def sendShareViaServer(baseDir, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, newShareJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, newShareJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
@ -483,7 +482,6 @@ def sendUndoShareViaServer(baseDir: str, session,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache, projectVersion,
|
personCache, projectVersion,
|
||||||
httpPrefix, fromNickname,
|
httpPrefix, fromNickname,
|
||||||
|
@ -506,7 +504,7 @@ def sendUndoShareViaServer(baseDir: str, session,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, undoShareJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, undoShareJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
|
|
@ -152,7 +152,6 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache, projectVersion,
|
personCache, projectVersion,
|
||||||
httpPrefix, nickname, domain,
|
httpPrefix, nickname, domain,
|
||||||
|
@ -175,7 +174,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult = \
|
postResult = \
|
||||||
postJson(session, newSkillJson, [], inboxUrl, headers, "inbox:write")
|
postJson(session, newSkillJson, [], inboxUrl, headers)
|
||||||
if not postResult:
|
if not postResult:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
|
|
|
@ -65,7 +65,6 @@ def instancesGraph(baseDir: str, handles: str,
|
||||||
|
|
||||||
(personUrl, pubKeyId, pubKey,
|
(personUrl, pubKeyId, pubKey,
|
||||||
personId, shaedInbox,
|
personId, shaedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
|
30
tests.py
30
tests.py
|
@ -239,7 +239,7 @@ def testThreads():
|
||||||
def createServerAlice(path: str, domain: str, port: int,
|
def createServerAlice(path: str, domain: str, port: int,
|
||||||
bobAddress: str, federationList: [],
|
bobAddress: str, federationList: [],
|
||||||
hasFollows: bool, hasPosts: bool,
|
hasFollows: bool, hasPosts: bool,
|
||||||
ocapAlways: bool, sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Alice on port ' + str(port))
|
print('Creating test server: Alice on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
@ -296,7 +296,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
httpPrefix, federationList, maxMentions, maxEmoji, False,
|
httpPrefix, federationList, maxMentions, maxEmoji, False,
|
||||||
noreply, nolike, nopics, noannounce, cw, ocapAlways,
|
noreply, nolike, nopics, noannounce, cw,
|
||||||
proxyType, maxReplies,
|
proxyType, maxReplies,
|
||||||
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
||||||
allowDeletion, True, True, False, sendThreads, False,
|
allowDeletion, True, True, False, sendThreads, False,
|
||||||
|
@ -306,7 +306,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
def createServerBob(path: str, domain: str, port: int,
|
def createServerBob(path: str, domain: str, port: int,
|
||||||
aliceAddress: str, federationList: [],
|
aliceAddress: str, federationList: [],
|
||||||
hasFollows: bool, hasPosts: bool,
|
hasFollows: bool, hasPosts: bool,
|
||||||
ocapAlways: bool, sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Bob on port ' + str(port))
|
print('Creating test server: Bob on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
@ -364,7 +364,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
httpPrefix, federationList, maxMentions, maxEmoji, False,
|
httpPrefix, federationList, maxMentions, maxEmoji, False,
|
||||||
noreply, nolike, nopics, noannounce, cw, ocapAlways,
|
noreply, nolike, nopics, noannounce, cw,
|
||||||
proxyType, maxReplies,
|
proxyType, maxReplies,
|
||||||
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
||||||
allowDeletion, True, True, False, sendThreads, False,
|
allowDeletion, True, True, False, sendThreads, False,
|
||||||
|
@ -373,7 +373,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
|
|
||||||
def createServerEve(path: str, domain: str, port: int, federationList: [],
|
def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
hasFollows: bool, hasPosts: bool,
|
hasFollows: bool, hasPosts: bool,
|
||||||
ocapAlways: bool, sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Eve on port ' + str(port))
|
print('Creating test server: Eve on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
@ -406,7 +406,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
"instanceId", False, path, domain,
|
"instanceId", False, path, domain,
|
||||||
onionDomain, i2pDomain, None, port, port,
|
onionDomain, i2pDomain, None, port, port,
|
||||||
httpPrefix, federationList, maxMentions, maxEmoji, False,
|
httpPrefix, federationList, maxMentions, maxEmoji, False,
|
||||||
noreply, nolike, nopics, noannounce, cw, ocapAlways,
|
noreply, nolike, nopics, noannounce, cw,
|
||||||
proxyType, maxReplies, allowDeletion, True, True, False,
|
proxyType, maxReplies, allowDeletion, True, True, False,
|
||||||
sendThreads, False, False)
|
sendThreads, False, False)
|
||||||
|
|
||||||
|
@ -427,8 +427,6 @@ def testPostMessageBetweenServers():
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests')
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
ocapAlways = False
|
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
aliceDir = baseDir + '/.tests/alice'
|
aliceDir = baseDir + '/.tests/alice'
|
||||||
aliceDomain = '127.0.0.50'
|
aliceDomain = '127.0.0.50'
|
||||||
|
@ -454,7 +452,7 @@ def testPostMessageBetweenServers():
|
||||||
threadWithTrace(target=createServerAlice,
|
threadWithTrace(target=createServerAlice,
|
||||||
args=(aliceDir, aliceDomain, alicePort, bobAddress,
|
args=(aliceDir, aliceDomain, alicePort, bobAddress,
|
||||||
federationList, False, False,
|
federationList, False, False,
|
||||||
ocapAlways, aliceSendThreads),
|
aliceSendThreads),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
|
|
||||||
global thrBob
|
global thrBob
|
||||||
|
@ -468,7 +466,7 @@ def testPostMessageBetweenServers():
|
||||||
threadWithTrace(target=createServerBob,
|
threadWithTrace(target=createServerBob,
|
||||||
args=(bobDir, bobDomain, bobPort, aliceAddress,
|
args=(bobDir, bobDomain, bobPort, aliceAddress,
|
||||||
federationList, False, False,
|
federationList, False, False,
|
||||||
ocapAlways, bobSendThreads),
|
bobSendThreads),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
|
|
||||||
thrAlice.start()
|
thrAlice.start()
|
||||||
|
@ -687,8 +685,6 @@ def testFollowBetweenServers():
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests')
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
ocapAlways = False
|
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
aliceDir = baseDir + '/.tests/alice'
|
aliceDir = baseDir + '/.tests/alice'
|
||||||
aliceDomain = '127.0.0.47'
|
aliceDomain = '127.0.0.47'
|
||||||
|
@ -713,7 +709,7 @@ def testFollowBetweenServers():
|
||||||
threadWithTrace(target=createServerAlice,
|
threadWithTrace(target=createServerAlice,
|
||||||
args=(aliceDir, aliceDomain, alicePort, bobAddress,
|
args=(aliceDir, aliceDomain, alicePort, bobAddress,
|
||||||
federationList, False, False,
|
federationList, False, False,
|
||||||
ocapAlways, aliceSendThreads),
|
aliceSendThreads),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
|
|
||||||
global thrBob
|
global thrBob
|
||||||
|
@ -727,7 +723,7 @@ def testFollowBetweenServers():
|
||||||
threadWithTrace(target=createServerBob,
|
threadWithTrace(target=createServerBob,
|
||||||
args=(bobDir, bobDomain, bobPort, aliceAddress,
|
args=(bobDir, bobDomain, bobPort, aliceAddress,
|
||||||
federationList, False, False,
|
federationList, False, False,
|
||||||
ocapAlways, bobSendThreads),
|
bobSendThreads),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
|
|
||||||
thrAlice.start()
|
thrAlice.start()
|
||||||
|
@ -1246,8 +1242,6 @@ def testClientToServer():
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests')
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
ocapAlways = False
|
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
aliceDir = baseDir + '/.tests/alice'
|
aliceDir = baseDir + '/.tests/alice'
|
||||||
aliceDomain = '127.0.0.42'
|
aliceDomain = '127.0.0.42'
|
||||||
|
@ -1272,7 +1266,7 @@ def testClientToServer():
|
||||||
threadWithTrace(target=createServerAlice,
|
threadWithTrace(target=createServerAlice,
|
||||||
args=(aliceDir, aliceDomain, alicePort, bobAddress,
|
args=(aliceDir, aliceDomain, alicePort, bobAddress,
|
||||||
federationList, False, False,
|
federationList, False, False,
|
||||||
ocapAlways, aliceSendThreads),
|
aliceSendThreads),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
|
|
||||||
global thrBob
|
global thrBob
|
||||||
|
@ -1286,7 +1280,7 @@ def testClientToServer():
|
||||||
threadWithTrace(target=createServerBob,
|
threadWithTrace(target=createServerBob,
|
||||||
args=(bobDir, bobDomain, bobPort, aliceAddress,
|
args=(bobDir, bobDomain, bobPort, aliceAddress,
|
||||||
federationList, False, False,
|
federationList, False, False,
|
||||||
ocapAlways, bobSendThreads),
|
bobSendThreads),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
|
|
||||||
thrAlice.start()
|
thrAlice.start()
|
||||||
|
|
2
utils.py
2
utils.py
|
@ -242,7 +242,7 @@ def domainPermitted(domain: str, federationList: []):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def urlPermitted(url: str, federationList: [], capability: str):
|
def urlPermitted(url: str, federationList: []):
|
||||||
if isEvil(url):
|
if isEvil(url):
|
||||||
return False
|
return False
|
||||||
if not federationList:
|
if not federationList:
|
||||||
|
|
|
@ -2650,7 +2650,7 @@ def htmlFooter() -> str:
|
||||||
def htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
|
def htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
translate: {},
|
translate: {},
|
||||||
baseDir: str, httpPrefix: str,
|
baseDir: str, httpPrefix: str,
|
||||||
authorized: bool, ocapAlways: bool,
|
authorized: bool,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
session, wfRequest: {}, personCache: {},
|
session, wfRequest: {}, personCache: {},
|
||||||
projectVersion: str,
|
projectVersion: str,
|
||||||
|
@ -2671,8 +2671,7 @@ def htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
str(currPage),
|
str(currPage),
|
||||||
httpPrefix,
|
httpPrefix,
|
||||||
10, 'outbox',
|
10, 'outbox',
|
||||||
authorized,
|
authorized)
|
||||||
ocapAlways)
|
|
||||||
if not outboxFeed:
|
if not outboxFeed:
|
||||||
break
|
break
|
||||||
if len(outboxFeed['orderedItems']) == 0:
|
if len(outboxFeed['orderedItems']) == 0:
|
||||||
|
@ -2700,7 +2699,7 @@ def htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
|
|
||||||
|
|
||||||
def htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
|
def htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
|
||||||
authorized: bool, ocapAlways: bool,
|
authorized: bool,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
session, wfRequest: {}, personCache: {},
|
session, wfRequest: {}, personCache: {},
|
||||||
followingJson: {}, projectVersion: str,
|
followingJson: {}, projectVersion: str,
|
||||||
|
@ -2930,7 +2929,7 @@ def htmlProfile(defaultTimeline: str,
|
||||||
recentPostsCache: {}, maxRecentPosts: int,
|
recentPostsCache: {}, maxRecentPosts: int,
|
||||||
translate: {}, projectVersion: str,
|
translate: {}, projectVersion: str,
|
||||||
baseDir: str, httpPrefix: str, authorized: bool,
|
baseDir: str, httpPrefix: str, authorized: bool,
|
||||||
ocapAlways: bool, profileJson: {}, selected: str,
|
profileJson: {}, selected: str,
|
||||||
session, wfRequest: {}, personCache: {},
|
session, wfRequest: {}, personCache: {},
|
||||||
YTReplacementDomain: str,
|
YTReplacementDomain: str,
|
||||||
extraJson=None,
|
extraJson=None,
|
||||||
|
@ -3190,14 +3189,14 @@ def htmlProfile(defaultTimeline: str,
|
||||||
htmlProfilePosts(recentPostsCache, maxRecentPosts,
|
htmlProfilePosts(recentPostsCache, maxRecentPosts,
|
||||||
translate,
|
translate,
|
||||||
baseDir, httpPrefix, authorized,
|
baseDir, httpPrefix, authorized,
|
||||||
ocapAlways, nickname, domain, port,
|
nickname, domain, port,
|
||||||
session, wfRequest, personCache,
|
session, wfRequest, personCache,
|
||||||
projectVersion,
|
projectVersion,
|
||||||
YTReplacementDomain) + licenseStr
|
YTReplacementDomain) + licenseStr
|
||||||
if selected == 'following':
|
if selected == 'following':
|
||||||
profileStr += \
|
profileStr += \
|
||||||
htmlProfileFollowing(translate, baseDir, httpPrefix,
|
htmlProfileFollowing(translate, baseDir, httpPrefix,
|
||||||
authorized, ocapAlways, nickname,
|
authorized, nickname,
|
||||||
domain, port, session,
|
domain, port, session,
|
||||||
wfRequest, personCache, extraJson,
|
wfRequest, personCache, extraJson,
|
||||||
projectVersion, ["unfollow"], selected,
|
projectVersion, ["unfollow"], selected,
|
||||||
|
@ -3205,7 +3204,7 @@ def htmlProfile(defaultTimeline: str,
|
||||||
if selected == 'followers':
|
if selected == 'followers':
|
||||||
profileStr += \
|
profileStr += \
|
||||||
htmlProfileFollowing(translate, baseDir, httpPrefix,
|
htmlProfileFollowing(translate, baseDir, httpPrefix,
|
||||||
authorized, ocapAlways, nickname,
|
authorized, nickname,
|
||||||
domain, port, session,
|
domain, port, session,
|
||||||
wfRequest, personCache, extraJson,
|
wfRequest, personCache, extraJson,
|
||||||
projectVersion, ["block"],
|
projectVersion, ["block"],
|
||||||
|
@ -3247,7 +3246,6 @@ def individualFollowAsHtml(translate: {},
|
||||||
if domain not in followUrl:
|
if domain not in followUrl:
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl2, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl2, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache, projectVersion,
|
personCache, projectVersion,
|
||||||
httpPrefix, nickname,
|
httpPrefix, nickname,
|
||||||
|
@ -4101,7 +4099,6 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
if fullDomain not in postActor:
|
if fullDomain not in postActor:
|
||||||
(inboxUrl, pubKeyId, pubKey,
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
fromPersonId, sharedInbox,
|
fromPersonId, sharedInbox,
|
||||||
capabilityAcquisition,
|
|
||||||
avatarUrl2, displayName) = getPersonBox(baseDir, session, wfRequest,
|
avatarUrl2, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
personCache,
|
personCache,
|
||||||
projectVersion, httpPrefix,
|
projectVersion, httpPrefix,
|
||||||
|
|
Loading…
Reference in New Issue