mirror of https://gitlab.com/bashrc2/epicyon
Confirm screen for deleting posts
parent
a6528d9dd7
commit
3d01f3c2af
54
daemon.py
54
daemon.py
|
@ -76,6 +76,7 @@ from roles import setRole
|
||||||
from roles import clearModeratorStatus
|
from roles import clearModeratorStatus
|
||||||
from skills import outboxSkills
|
from skills import outboxSkills
|
||||||
from availability import outboxAvailability
|
from availability import outboxAvailability
|
||||||
|
from webinterface import htmlDeletePost
|
||||||
from webinterface import htmlAbout
|
from webinterface import htmlAbout
|
||||||
from webinterface import htmlRemoveSharedItem
|
from webinterface import htmlRemoveSharedItem
|
||||||
from webinterface import htmlInboxDMs
|
from webinterface import htmlInboxDMs
|
||||||
|
@ -1022,19 +1023,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.postToNickname=getNicknameFromActor(actor)
|
self.postToNickname=getNicknameFromActor(actor)
|
||||||
if not self.server.session:
|
if not self.server.session:
|
||||||
self.server.session= \
|
self.server.session= \
|
||||||
createSession(self.server.domain,self.server.port,self.server.useTor)
|
createSession(self.server.domain,self.server.port, \
|
||||||
deleteActor=self.server.httpPrefix+'://'+self.server.domainFull+'/users/'+self.postToNickname
|
self.server.useTor)
|
||||||
deleteJson= {
|
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
deleteStr= \
|
||||||
'actor': actor,
|
htmlDeletePost(self.server.session,self.server.baseDir, \
|
||||||
'object': deleteUrl,
|
deleteUrl,self.server.httpPrefix, \
|
||||||
'to': ['https://www.w3.org/ns/activitystreams#Public',actor],
|
__version__,self.server.cachedWebfingers, \
|
||||||
'cc': [actor+'/followers'],
|
self.server.personCache)
|
||||||
'type': 'Delete'
|
if deleteStr:
|
||||||
}
|
self._set_headers('text/html',len(deleteStr),cookie)
|
||||||
if self.server.debug:
|
self.wfile.write(deleteStr)
|
||||||
pprint(deleteJson)
|
self.server.GETbusy=False
|
||||||
self._postToOutbox(deleteJson)
|
return
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
self._redirect_headers(actor+'/inbox',cookie)
|
self._redirect_headers(actor+'/inbox',cookie)
|
||||||
return
|
return
|
||||||
|
@ -2579,6 +2580,33 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.POSTbusy=False
|
self.server.POSTbusy=False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# removes a post
|
||||||
|
if authorized and self.path.endswith('/rmpost'):
|
||||||
|
originPathStr=self.path.split('/rmpost')[0]
|
||||||
|
length = int(self.headers['Content-length'])
|
||||||
|
removePostConfirmParams=self.rfile.read(length).decode('utf-8')
|
||||||
|
if '&submitYes=' in removePostConfirmParams:
|
||||||
|
removePostConfirmParams=removePostConfirmParams.replace('%3A',':').replace('%2F','/')
|
||||||
|
removeMessageId=removePostConfirmParams.split('messageId=')[1]
|
||||||
|
if '&' in removeMessageId:
|
||||||
|
removeMessageId=removeMessageId.split('&')[0]
|
||||||
|
if '/statuses/' in removeMessageId:
|
||||||
|
removePostActor=removeMessageId.split('/statuses/')[0]
|
||||||
|
deleteJson= {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
'actor': removePostActor,
|
||||||
|
'object': removeMessageId,
|
||||||
|
'to': ['https://www.w3.org/ns/activitystreams#Public',removePostActor],
|
||||||
|
'cc': [removePostActor+'/followers'],
|
||||||
|
'type': 'Delete'
|
||||||
|
}
|
||||||
|
if self.server.debug:
|
||||||
|
pprint(deleteJson)
|
||||||
|
self._postToOutbox(deleteJson)
|
||||||
|
self._redirect_headers(originPathStr+'/outbox',cookie)
|
||||||
|
self.server.POSTbusy=False
|
||||||
|
return
|
||||||
|
|
||||||
# decision to follow in the web interface is confirmed
|
# decision to follow in the web interface is confirmed
|
||||||
if authorized and self.path.endswith('/followconfirm'):
|
if authorized and self.path.endswith('/followconfirm'):
|
||||||
originPathStr=self.path.split('/followconfirm')[0]
|
originPathStr=self.path.split('/followconfirm')[0]
|
||||||
|
|
|
@ -1658,7 +1658,50 @@ def htmlRemoveSharedItem(baseDir: str,actor: str,shareName: str) -> str:
|
||||||
sharesStr+='</div>'
|
sharesStr+='</div>'
|
||||||
sharesStr+=htmlFooter()
|
sharesStr+=htmlFooter()
|
||||||
return sharesStr
|
return sharesStr
|
||||||
|
|
||||||
|
def htmlDeletePost(session,baseDir: str,messageId: str, \
|
||||||
|
httpPrefix: str,projectVersion: str, \
|
||||||
|
wfRequest: {},personCache: {}) -> str:
|
||||||
|
"""Shows a screen asking to confirm the deletion of a post
|
||||||
|
"""
|
||||||
|
if '/statuses/' not in messageId:
|
||||||
|
return None
|
||||||
|
|
||||||
|
actor=messageId.split('/statuses/')[0]
|
||||||
|
nickname=getNicknameFromActor(actor)
|
||||||
|
domain,port=getDomainFromActor(actor)
|
||||||
|
|
||||||
|
postFilename=locatePost(baseDir,nickname,domain,messageId)
|
||||||
|
if not postFilename:
|
||||||
|
return None
|
||||||
|
with open(postFilename, 'r') as fp:
|
||||||
|
postJsonObject=commentjson.load(fp)
|
||||||
|
|
||||||
|
if os.path.isfile(baseDir+'/img/delete-background.png'):
|
||||||
|
if not os.path.isfile(baseDir+'/accounts/delete-background.png'):
|
||||||
|
copyfile(baseDir+'/img/delete-background.png',baseDir+'/accounts/delete-background.png')
|
||||||
|
|
||||||
|
with open(baseDir+'/epicyon-follow.css', 'r') as cssFile:
|
||||||
|
profileStyle = cssFile.read()
|
||||||
|
deletePostStr=htmlHeader(profileStyle)
|
||||||
|
deletePostStr+= \
|
||||||
|
individualPostAsHtml(baseDir,session,wfRequest,personCache, \
|
||||||
|
nickname,domain,port,postJsonObject, \
|
||||||
|
None,True,False, \
|
||||||
|
httpPrefix,projectVersion, \
|
||||||
|
False,False)
|
||||||
|
deletePostStr+='<center>'
|
||||||
|
deletePostStr+=' <p class="followText">Delete this post?</p>'
|
||||||
|
deletePostStr+= \
|
||||||
|
' <form method="POST" action="'+actor+'/rmpost">' \
|
||||||
|
' <input type="hidden" name="messageId" value="'+messageId+'">' \
|
||||||
|
' <button type="submit" class="button" name="submitYes">Yes</button>' \
|
||||||
|
' <a href="'+actor+'/inbox'+'"><button class="button">No</button></a>' \
|
||||||
|
' </form>'
|
||||||
|
deletePostStr+='</center>'
|
||||||
|
deletePostStr+=htmlFooter()
|
||||||
|
return deletePostStr
|
||||||
|
|
||||||
def htmlFollowConfirm(baseDir: str,originPathStr: str,followActor: str,followProfileUrl: str) -> str:
|
def htmlFollowConfirm(baseDir: str,originPathStr: str,followActor: str,followProfileUrl: str) -> str:
|
||||||
"""Asks to confirm a follow
|
"""Asks to confirm a follow
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue