mirror of https://gitlab.com/bashrc2/epicyon
Function to return featured post collection
parent
bb3be870e7
commit
36c9827ce4
35
daemon.py
35
daemon.py
|
@ -8951,6 +8951,34 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _getFeaturedCollection(self, callingDomain: str,
|
||||||
|
path: str,
|
||||||
|
httpPrefix: str,
|
||||||
|
domainFull: str):
|
||||||
|
"""Returns the featured posts collections in
|
||||||
|
actor/collections/featured
|
||||||
|
TODO add ability to set a featured post
|
||||||
|
"""
|
||||||
|
featuredCollection = {
|
||||||
|
'@context': ['https://www.w3.org/ns/activitystreams',
|
||||||
|
{'atomUri': 'ostatus:atomUri',
|
||||||
|
'conversation': 'ostatus:conversation',
|
||||||
|
'inReplyToAtomUri': 'ostatus:inReplyToAtomUri',
|
||||||
|
'sensitive': 'as:sensitive',
|
||||||
|
'toot': 'http://joinmastodon.org/ns#',
|
||||||
|
'votersCount': 'toot:votersCount'}],
|
||||||
|
'id': httpPrefix + '://' + domainFull + path,
|
||||||
|
'orderedItems': [],
|
||||||
|
'totalItems': 1,
|
||||||
|
'type': 'OrderedCollection'
|
||||||
|
}
|
||||||
|
msg = json.dumps(featuredCollection,
|
||||||
|
ensure_ascii=False).encode('utf-8')
|
||||||
|
msglen = len(msg)
|
||||||
|
self._set_headers('application/json', msglen,
|
||||||
|
None, callingDomain)
|
||||||
|
self._write(msg)
|
||||||
|
|
||||||
def _showPersonProfile(self, authorized: bool,
|
def _showPersonProfile(self, authorized: bool,
|
||||||
callingDomain: str, path: str,
|
callingDomain: str, path: str,
|
||||||
baseDir: str, httpPrefix: str,
|
baseDir: str, httpPrefix: str,
|
||||||
|
@ -9980,6 +10008,13 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/users/' in self.path:
|
if '/users/' in self.path:
|
||||||
usersInPath = True
|
usersInPath = True
|
||||||
|
|
||||||
|
if usersInPath and self.path.endswith('/collections/featured'):
|
||||||
|
self._getFeaturedCollection(callingDomain,
|
||||||
|
self.path,
|
||||||
|
self.server.httpPrefix,
|
||||||
|
self.server.domainFull)
|
||||||
|
return
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
'sharedInbox enabled', 'rss3 done')
|
'sharedInbox enabled', 'rss3 done')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue