From 3d8277dcabf442a7bfa389972b9595b526f549c5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 11 Aug 2019 21:38:10 +0100 Subject: [PATCH] Add moderation status to post --- epicyon-profile.css | 6 ++++++ posts.py | 31 ++++++++++++++++++++----------- webinterface.py | 2 ++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/epicyon-profile.css b/epicyon-profile.css index 23e700ce..390b7e5b 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -3,6 +3,7 @@ :root { --main-bg-color: #282c37; --main-bg-color-darker: #232c37; + --main-bg-color-report: #221c27; --main-header-color-roles: #282237; --main-fg-color: #dddddd; --main-link-color: #999; @@ -372,6 +373,11 @@ a:link { background-color: var(--main-bg-color-darker); } +.report { + border-color: #255; + background-color: var(--main-bg-color-report); +} + .container img.attachment { max-width: 100%; margin-left: 25%; diff --git a/posts.py b/posts.py index 3d231de0..3d075788 100644 --- a/posts.py +++ b/posts.py @@ -392,9 +392,10 @@ def updateHashtagsIndex(baseDir: str,tag: {},newPostId: str) -> None: def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ toUrl: str, ccUrl: str, httpPrefix: str, content: str, \ - followersOnly: bool, saveToFile: bool, clientToServer: bool, - attachImageFilename: str,imageDescription: str,useBlurhash: bool, \ - inReplyTo=None, inReplyToAtomUri=None, subject=None) -> {}: + followersOnly: bool, saveToFile: bool, clientToServer: bool, \ + attachImageFilename: str,imageDescription: str, \ + useBlurhash: bool,isModerationReport: bool,inReplyTo=None, \ + inReplyToAtomUri=None, subject=None) -> {}: """Creates a message """ mentionedRecipients=[] @@ -421,7 +422,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ postTo=postCC postCC='' newPostId=httpPrefix+'://'+domain+'/users/'+nickname+'/statuses/'+statusNumber - + sensitive=False summary=None if subject: @@ -547,6 +548,14 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ newPost['cc']=[ccUrl] if newPost.get('object'): newPost['object']['cc']=[ccUrl] + + # if this is a moderation report then add a status + if isModerationReport: + if newPost.get('object'): + newPost['object']['moderationStatus']='pending' + else: + newPost['moderationStatus']='pending' + if saveToFile: savePostToBox(baseDir,httpPrefix,newPostId, \ nickname,domain,newPost,'outbox') @@ -663,7 +672,7 @@ def createPublicPost(baseDir: str, httpPrefix, content, followersOnly, saveToFile, \ clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - inReplyTo, inReplyToAtomUri, subject) + False,inReplyTo,inReplyToAtomUri,subject) def createUnlistedPost(baseDir: str, nickname: str, domain: str, port: int,httpPrefix: str, \ @@ -683,7 +692,7 @@ def createUnlistedPost(baseDir: str, httpPrefix, content, followersOnly, saveToFile, \ clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - inReplyTo, inReplyToAtomUri, subject) + False,inReplyTo, inReplyToAtomUri, subject) def createFollowersOnlyPost(baseDir: str, nickname: str, domain: str, port: int,httpPrefix: str, \ @@ -703,7 +712,7 @@ def createFollowersOnlyPost(baseDir: str, httpPrefix, content, followersOnly, saveToFile, \ clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - inReplyTo, inReplyToAtomUri, subject) + False,inReplyTo, inReplyToAtomUri, subject) def getMentionedPeople(baseDir: str,httpPrefix: str,content: str,domain: str) -> []: """Extracts a list of mentioned actors from the given message content @@ -752,7 +761,7 @@ def createDirectMessagePost(baseDir: str, httpPrefix, content, followersOnly, saveToFile, \ clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - inReplyTo, inReplyToAtomUri, subject) + False,inReplyTo, inReplyToAtomUri, subject) def createReportPost(baseDir: str, nickname: str, domain: str, port: int,httpPrefix: str, \ @@ -823,7 +832,7 @@ def createReportPost(baseDir: str, httpPrefix, content, followersOnly, saveToFile, \ clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - None, None, subject) + True,None, None, subject) return postJsonObject def threadSendPost(session,postJsonObject: {},federationList: [],\ @@ -914,7 +923,7 @@ def sendPost(session,baseDir: str,nickname: str, domain: str, port: int, \ toPersonId,cc,httpPrefix,content, \ followersOnly,saveToFile,clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - inReplyTo,inReplyToAtomUri,subject) + False,inReplyTo,inReplyToAtomUri,subject) # get the senders private key privateKeyPem=getPersonKey(nickname,domain,baseDir,'private') @@ -1013,7 +1022,7 @@ def sendPostViaServer(baseDir,session,fromNickname: str,password: str, \ toPersonId,cc,httpPrefix,content, \ followersOnly,saveToFile,clientToServer, \ attachImageFilename,imageDescription,useBlurhash, \ - inReplyTo,inReplyToAtomUri,subject) + False,inReplyTo,inReplyToAtomUri,subject) authHeader=createBasicAuthHeader(fromNickname,password) diff --git a/webinterface.py b/webinterface.py index 081b3cfa..970c2d0b 100644 --- a/webinterface.py +++ b/webinterface.py @@ -934,6 +934,8 @@ def individualPostAsHtml(baseDir: str, \ contentStr='' if postJsonObject['object'].get('summary'): contentStr+=''+postJsonObject['object']['summary']+' ' + if postJsonObject['object'].get('moderationStatus'): + containerClass='container report' else: contentStr+='Sensitive ' contentStr+=''