mirror of https://gitlab.com/bashrc2/epicyon
Replies timeline
parent
e311b995de
commit
7ed6728594
|
@ -19,6 +19,7 @@ from shutil import copyfile
|
||||||
from webfinger import createWebfingerEndpoint
|
from webfinger import createWebfingerEndpoint
|
||||||
from webfinger import storeWebfingerEndpoint
|
from webfinger import storeWebfingerEndpoint
|
||||||
from posts import createDMTimeline
|
from posts import createDMTimeline
|
||||||
|
from posts import createRepliesTimeline
|
||||||
from posts import createInbox
|
from posts import createInbox
|
||||||
from posts import createOutbox
|
from posts import createOutbox
|
||||||
from posts import createModeration
|
from posts import createModeration
|
||||||
|
@ -400,6 +401,7 @@ def personBoxJson(baseDir: str,domain: str,port: int,path: str, \
|
||||||
"""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 \
|
||||||
|
boxname!='replies' and \
|
||||||
boxname!='outbox' and boxname!='moderation':
|
boxname!='outbox' and boxname!='moderation':
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -440,6 +442,9 @@ def personBoxJson(baseDir: str,domain: str,port: int,path: str, \
|
||||||
if boxname=='dm':
|
if boxname=='dm':
|
||||||
return createDMTimeline(baseDir,nickname,domain,port,httpPrefix, \
|
return createDMTimeline(baseDir,nickname,domain,port,httpPrefix, \
|
||||||
noOfItems,headerOnly,ocapAlways,pageNumber)
|
noOfItems,headerOnly,ocapAlways,pageNumber)
|
||||||
|
elif boxname=='replies':
|
||||||
|
return createRepliesTimeline(baseDir,nickname,domain,port,httpPrefix, \
|
||||||
|
noOfItems,headerOnly,ocapAlways,pageNumber)
|
||||||
elif boxname=='outbox':
|
elif boxname=='outbox':
|
||||||
return createOutbox(baseDir,nickname,domain,port,httpPrefix, \
|
return createOutbox(baseDir,nickname,domain,port,httpPrefix, \
|
||||||
noOfItems,headerOnly,authorized,pageNumber)
|
noOfItems,headerOnly,authorized,pageNumber)
|
||||||
|
|
31
posts.py
31
posts.py
|
@ -1579,6 +1579,11 @@ def createDMTimeline(baseDir: str,nickname: str,domain: str,port: int,httpPrefix
|
||||||
return createBoxBase(baseDir,'dm',nickname,domain,port,httpPrefix, \
|
return createBoxBase(baseDir,'dm',nickname,domain,port,httpPrefix, \
|
||||||
itemsPerPage,headerOnly,True,ocapAlways,pageNumber)
|
itemsPerPage,headerOnly,True,ocapAlways,pageNumber)
|
||||||
|
|
||||||
|
def createRepliesTimeline(baseDir: str,nickname: str,domain: str,port: int,httpPrefix: str, \
|
||||||
|
itemsPerPage: int,headerOnly: bool,ocapAlways: bool,pageNumber=None) -> {}:
|
||||||
|
return createBoxBase(baseDir,'replies',nickname,domain,port,httpPrefix, \
|
||||||
|
itemsPerPage,headerOnly,True,ocapAlways,pageNumber)
|
||||||
|
|
||||||
def createOutbox(baseDir: str,nickname: str,domain: str,port: int,httpPrefix: str, \
|
def createOutbox(baseDir: str,nickname: str,domain: str,port: int,httpPrefix: str, \
|
||||||
itemsPerPage: int,headerOnly: bool,authorized: bool,pageNumber=None) -> {}:
|
itemsPerPage: int,headerOnly: bool,authorized: bool,pageNumber=None) -> {}:
|
||||||
return createBoxBase(baseDir,'outbox',nickname,domain,port,httpPrefix, \
|
return createBoxBase(baseDir,'outbox',nickname,domain,port,httpPrefix, \
|
||||||
|
@ -1678,6 +1683,23 @@ def isDM(postJsonObject: {}) -> bool:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def isReply(postJsonObject: {},actor: str) -> bool:
|
||||||
|
"""Returns true if the given post is a reply to the given actor
|
||||||
|
"""
|
||||||
|
if postJsonObject['type']!='Create':
|
||||||
|
return False
|
||||||
|
if not postJsonObject.get('object'):
|
||||||
|
return False
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
return False
|
||||||
|
if postJsonObject['object']['type']!='Note':
|
||||||
|
return False
|
||||||
|
if not postJsonObject['object'].get('inReplyTo'):
|
||||||
|
return False
|
||||||
|
if not postJsonObject['object']['inReplyTo'].startswith(actor)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def createBoxBase(baseDir: str,boxname: str, \
|
def createBoxBase(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, \
|
||||||
|
@ -1686,7 +1708,7 @@ def createBoxBase(baseDir: str,boxname: str, \
|
||||||
"""
|
"""
|
||||||
if boxname!='inbox' and boxname!='dm' and boxname!='outbox':
|
if boxname!='inbox' and boxname!='dm' and boxname!='outbox':
|
||||||
return None
|
return None
|
||||||
if boxname!='dm':
|
if boxname!='dm' and boxname!='replies':
|
||||||
boxDir = createPersonDir(nickname,domain,baseDir,boxname)
|
boxDir = createPersonDir(nickname,domain,baseDir,boxname)
|
||||||
else:
|
else:
|
||||||
# extract DMs from the inbox
|
# extract DMs from the inbox
|
||||||
|
@ -1700,6 +1722,8 @@ def createBoxBase(baseDir: str,boxname: str, \
|
||||||
if ':' not in domain:
|
if ':' not in domain:
|
||||||
domain=domain+':'+str(port)
|
domain=domain+':'+str(port)
|
||||||
|
|
||||||
|
boxActor=httpPrefix+'://'+domain+'/users/'+nickname
|
||||||
|
|
||||||
pageStr='?page=true'
|
pageStr='?page=true'
|
||||||
if pageNumber:
|
if pageNumber:
|
||||||
try:
|
try:
|
||||||
|
@ -1834,8 +1858,9 @@ def createBoxBase(baseDir: str,boxname: str, \
|
||||||
# get the post as json
|
# get the post as json
|
||||||
p = json.loads(postStr)
|
p = json.loads(postStr)
|
||||||
|
|
||||||
if boxname!='dm' or \
|
if (boxname!='dm' and boxname!='replies') or \
|
||||||
(boxname=='dm' and isDM(p)):
|
(boxname=='dm' and isDM(p)) or \
|
||||||
|
(boxname=='replies' and (isReply(p,boxActor) or isDM(p))):
|
||||||
# remove any capability so that it's not displayed
|
# remove any capability so that it's not displayed
|
||||||
if p.get('capability'):
|
if p.get('capability'):
|
||||||
del p['capability']
|
del p['capability']
|
||||||
|
|
Loading…
Reference in New Issue