forked from indymedia/epicyon
Basic moderation functions
parent
727c8ca6fc
commit
4a80c94cbe
25
daemon.py
25
daemon.py
|
@ -29,6 +29,7 @@ from person import createSharedInbox
|
|||
from person import isSuspended
|
||||
from person import suspendAccount
|
||||
from person import unsuspendAccount
|
||||
from person import removeAccount
|
||||
from posts import outboxMessageCreateWrap
|
||||
from posts import savePostToBox
|
||||
from posts import sendToFollowers
|
||||
|
@ -2109,7 +2110,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
moderationText=None
|
||||
moderationButton=None
|
||||
for moderationStr in moderationParams.split('&'):
|
||||
if moderationStr=='moderationAction':
|
||||
print('moderationStr: '+moderationStr)
|
||||
if moderationStr.startswith('moderationAction'):
|
||||
if '=' in moderationStr:
|
||||
moderationText=moderationStr.split('=')[1].strip()
|
||||
moderationText=moderationText.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
|
||||
|
@ -2124,6 +2126,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
elif moderationStr.startswith('submitRemove'):
|
||||
moderationButton='remove'
|
||||
if moderationButton and moderationText:
|
||||
if self.server.debug:
|
||||
print('moderationButton: '+moderationButton)
|
||||
print('moderationText: '+moderationText)
|
||||
nickname=moderationText
|
||||
if nickname.startswith('http') or \
|
||||
nickname.startswith('dat'):
|
||||
|
@ -2131,9 +2136,27 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if '@' in nickname:
|
||||
nickname=nickname.split('@')[0]
|
||||
if moderationButton=='suspend':
|
||||
print('**************** suspend')
|
||||
suspendAccount(self.server.baseDir,nickname,self.server.salts)
|
||||
if moderationButton=='unsuspend':
|
||||
unsuspendAccount(self.server.baseDir,nickname)
|
||||
if moderationButton=='remove':
|
||||
if '/statuses/' not in moderationText:
|
||||
removeAccount(self.server.baseDir, \
|
||||
nickname, \
|
||||
self.server.domain, \
|
||||
self.server.port)
|
||||
else:
|
||||
postFilename= \
|
||||
locatePost(self.server.baseDir, \
|
||||
nickname,self.server.domain, \
|
||||
moderationText)
|
||||
if postFilename:
|
||||
deletePost(self.server.baseDir, \
|
||||
self.server.httpPrefix, \
|
||||
nickname,self.server.omain, \
|
||||
postFilename, \
|
||||
self.server.debug)
|
||||
self._redirect_headers(actorStr+'/moderation',cookie)
|
||||
self.server.POSTbusy=False
|
||||
return
|
||||
|
|
|
@ -27,6 +27,7 @@ from roles import setRole
|
|||
from media import removeMetaData
|
||||
from utils import validNickname
|
||||
from utils import noOfAccounts
|
||||
from auth import createPassword
|
||||
from config import setConfigParam
|
||||
from config import getConfigParam
|
||||
|
||||
|
@ -564,7 +565,7 @@ def removeTagsForNickname(baseDir: str,nickname: str,domain: str,port: int) -> N
|
|||
|
||||
def removeAccount(baseDir: str,nickname: str,domain: str,port: int) -> bool:
|
||||
"""Removes an account
|
||||
"""
|
||||
"""
|
||||
# Don't remove the admin
|
||||
adminNickname=getConfigParam(baseDir,'admin')
|
||||
if nickname==adminNickname:
|
||||
|
|
|
@ -1046,8 +1046,7 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
|
|||
|
||||
moderationButtonStr=''
|
||||
if moderator:
|
||||
if noOfModerationPosts(baseDir)>0:
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue