Replies to moderation posts are direct messages

master
Bob Mottram 2019-08-12 15:48:19 +01:00
parent a078f1c394
commit 1254dc1052
2 changed files with 35 additions and 1 deletions

View File

@ -926,6 +926,7 @@ class PubServer(BaseHTTPRequestHandler):
# reply from the web interface icon # reply from the web interface icon
inReplyToUrl=None inReplyToUrl=None
replyWithDM=False
replyToList=[] replyToList=[]
if authorized and '?replyto=' in self.path: if authorized and '?replyto=' in self.path:
inReplyToUrl=self.path.split('?replyto=')[1] inReplyToUrl=self.path.split('?replyto=')[1]
@ -937,6 +938,17 @@ class PubServer(BaseHTTPRequestHandler):
inReplyToUrl=mentionsList[0] inReplyToUrl=mentionsList[0]
self.path=self.path.split('?replyto=')[0]+'/newpost' self.path=self.path.split('?replyto=')[0]+'/newpost'
# replying as a direct message, for moderation posts
if authorized and '?replydm=' in self.path:
inReplyToUrl=self.path.split('?replydm=')[1]
if '?' in inReplyToUrl:
mentionsList=inReplyToUrl.split('?')
for m in mentionsList:
if m.startswith('mention='):
replyToList.append(m.replace('mention=',''))
inReplyToUrl=mentionsList[0]
self.path=self.path.split('?replydm=')[0]+'/newdm'
# edit profile in web interface # edit profile in web interface
if '/users/' in self.path and self.path.endswith('/editprofile'): if '/users/' in self.path and self.path.endswith('/editprofile'):
self._set_headers('text/html',cookie) self._set_headers('text/html',cookie)

View File

@ -941,7 +941,10 @@ def individualPostAsHtml(baseDir: str, \
break break
footerStr='<div class="'+containerClassIcons+'">' footerStr='<div class="'+containerClassIcons+'">'
footerStr+='<a href="/users/'+nickname+'?replyto='+replyToLink+'" title="Reply to this post">' if not isModerationPost:
footerStr+='<a href="/users/'+nickname+'?replyto='+replyToLink+'" title="Reply to this post">'
else:
footerStr+='<a href="/users/'+nickname+'?replydm='+replyToLink+'" title="Reply to this post">'
footerStr+='<img src="/icons/reply.png"/></a>' footerStr+='<img src="/icons/reply.png"/></a>'
footerStr+=announceStr+likeStr+deleteStr footerStr+=announceStr+likeStr+deleteStr
footerStr+='<span class="'+timeClass+'">'+publishedStr+'</span>' footerStr+='<span class="'+timeClass+'">'+publishedStr+'</span>'
@ -1014,6 +1017,8 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
moderationButtonStr='<a href="'+actor+'/moderation"><button class="'+moderationButton+'"><span>Moderate </span></button></a>' moderationButtonStr='<a href="'+actor+'/moderation"><button class="'+moderationButton+'"><span>Moderate </span></button></a>'
tlStr=htmlHeader(profileStyle) tlStr=htmlHeader(profileStyle)
# banner and row of buttons
tlStr+= \ tlStr+= \
'<a href="/users/'+nickname+'" title="Switch to profile view" alt="Switch to profile view">' \ '<a href="/users/'+nickname+'" title="Switch to profile view" alt="Switch to profile view">' \
'<div class="timeline-banner">' \ '<div class="timeline-banner">' \
@ -1026,9 +1031,24 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
' <a href="'+actor+'/search"><img src="/icons/search.png" title="Search and follow" alt="Search and follow" class="right"/></a>'+ \ ' <a href="'+actor+'/search"><img src="/icons/search.png" title="Search and follow" alt="Search and follow" class="right"/></a>'+ \
followApprovals+ \ followApprovals+ \
'</div>' '</div>'
# second row of buttons for moderator actions
if moderator and boxName=='moderation':
tlStr+= \
'<div class="container">\n'+ \
' <a href="'+actor+'/modremove"><button title="Remove an account" class="button"><span>Remove </span></button></a>' \
' <a href="'+actor+'/modsuspend"><button title="Suspend an account" class="button"><span>Suspend </span></button></a>' \
' <a href="'+actor+'/modblock"><button title="Block an account on another instance" class="button"><span>Block </span></button></a>' \
'</div>'
# add the javascript for content warnings
tlStr+='<script>'+contentWarningScript()+'</script>' tlStr+='<script>'+contentWarningScript()+'</script>'
# page up arrow
if pageNumber>1: if pageNumber>1:
tlStr+='<center><a href="'+actor+'/'+boxName+'?page='+str(pageNumber-1)+'"><img class="pageicon" src="/icons/pageup.png" title="Page up" alt="Page up"></a></center>' tlStr+='<center><a href="'+actor+'/'+boxName+'?page='+str(pageNumber-1)+'"><img class="pageicon" src="/icons/pageup.png" title="Page up" alt="Page up"></a></center>'
# show the posts
itemCtr=0 itemCtr=0
for item in timelineJson['orderedItems']: for item in timelineJson['orderedItems']:
if item['type']=='Create' or item['type']=='Announce': if item['type']=='Create' or item['type']=='Announce':
@ -1036,6 +1056,8 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
tlStr+=individualPostAsHtml(baseDir,session,wfRequest,personCache, \ tlStr+=individualPostAsHtml(baseDir,session,wfRequest,personCache, \
nickname,domain,port,item,None,True, \ nickname,domain,port,item,None,True, \
allowDeletion,showIndividualPostIcons) allowDeletion,showIndividualPostIcons)
# page down arrow
if itemCtr>=itemsPerPage: if itemCtr>=itemsPerPage:
tlStr+='<center><a href="'+actor+'/'+boxName+'?page='+str(pageNumber+1)+'"><img class="pageicon" src="/icons/pagedown.png" title="Page down" alt="Page down"></a></center>' tlStr+='<center><a href="'+actor+'/'+boxName+'?page='+str(pageNumber+1)+'"><img class="pageicon" src="/icons/pagedown.png" title="Page down" alt="Page down"></a></center>'
tlStr+=htmlFooter() tlStr+=htmlFooter()