forked from indymedia/epicyon
Add content warnings for replies to posts which have content warnings
parent
7442097384
commit
cded055acc
21
posts.py
21
posts.py
|
@ -37,6 +37,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import deletePost
|
from utils import deletePost
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
|
from utils import locatePost
|
||||||
from capabilities import getOcapFilename
|
from capabilities import getOcapFilename
|
||||||
from capabilities import capabilitiesUpdate
|
from capabilities import capabilitiesUpdate
|
||||||
from media import attachMedia
|
from media import attachMedia
|
||||||
|
@ -507,6 +508,26 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
|
||||||
print('Content tags: '+str(tags))
|
print('Content tags: '+str(tags))
|
||||||
content=replaceEmojiFromTags(content,tags,'content')
|
content=replaceEmojiFromTags(content,tags,'content')
|
||||||
|
|
||||||
|
if inReplyTo and not sensitive:
|
||||||
|
# locate the post which this is a reply to and check if
|
||||||
|
# it has a content warning. If it does then reproduce
|
||||||
|
# the same warning
|
||||||
|
replyPostFilename=locatePost(baseDir,username,domain,inReplyTo)
|
||||||
|
if replyPostFilename:
|
||||||
|
replyToJson=None
|
||||||
|
try:
|
||||||
|
with open(replyPostFilename, 'r') as fp:
|
||||||
|
replyToJson=commentjson.load(fp)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
if replyToJson:
|
||||||
|
if replyToJson.get('object'):
|
||||||
|
if replyToJson['object'].get('sensitive'):
|
||||||
|
if replyToJson['object']['sensitive']:
|
||||||
|
sensitive=True
|
||||||
|
if replyToJson['object'].get('summary'):
|
||||||
|
summary=replyToJson['object']['summary']
|
||||||
|
|
||||||
if not clientToServer:
|
if not clientToServer:
|
||||||
actorUrl=httpPrefix+'://'+domain+'/users/'+nickname
|
actorUrl=httpPrefix+'://'+domain+'/users/'+nickname
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue