From eca0cbe9827d6ffc896359128e036ab1c9564c96 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 8 Oct 2020 10:07:45 +0100 Subject: [PATCH] Indicate that imported posts contain news --- newsdaemon.py | 1 + utils.py | 6 ++++++ webinterface.py | 27 +++++++++++++++------------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/newsdaemon.py b/newsdaemon.py index bb2e6d415..bc7b02398 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -105,6 +105,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, idStr = \ httpPrefix + '://' + domain + '/users/news' + \ '/statuses/' + statusNumber + '/replies' + blog['news'] = True blog['object']['replies']['id'] = idStr blog['object']['replies']['first']['partOf'] = idStr diff --git a/utils.py b/utils.py index 0d3977e7e..74f58ba52 100644 --- a/utils.py +++ b/utils.py @@ -979,6 +979,12 @@ def isBlogPost(postJsonObject: {}) -> bool: return True +def isNewsPost(postJsonObject: {}) -> bool: + """Is the given post a blog post? + """ + return postJsonObject.get('news') + + def searchBoxPosts(baseDir: str, nickname: str, domain: str, searchStr: str, maxResults: int, boxName='outbox') -> []: diff --git a/webinterface.py b/webinterface.py index 7ca718794..9a8c7ed91 100644 --- a/webinterface.py +++ b/webinterface.py @@ -30,6 +30,7 @@ from utils import getProtocolPrefixes from utils import searchBoxPosts from utils import isEventPost from utils import isBlogPost +from utils import isNewsPost from utils import updateRecentPostsCache from utils import getNicknameFromActor from utils import getDomainFromActor @@ -4512,18 +4513,20 @@ def individualPostAsHtml(allowDownloads: bool, if fullDomain + '/users/' + nickname in postJsonObject['actor']: if '/statuses/' in postJsonObject['object']['id']: if isBlogPost(postJsonObject): - blogPostId = postJsonObject['object']['id'] - editStr += \ - ' ' + \ - '' + \ - '' + \
-                    translate['Edit blog post'] + \
-                    ' |\n' + if not isNewsPost(postJsonObject): + blogPostId = postJsonObject['object']['id'] + editStr += \ + ' ' + \ + '' + \ + '' + \
+                        translate['Edit blog post'] + \
+                        ' |\n' elif isEvent: eventPostId = postJsonObject['object']['id'] editStr += \