From 2ce93f24d7bfd69d6901c5438d1e2820e65d2a7d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 18 Nov 2021 18:43:58 +0000 Subject: [PATCH] Page avtivity type --- git.py | 1 + posts.py | 13 ++++++++++--- utils.py | 2 ++ webapp_profile.py | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/git.py b/git.py index f5262751f..2cab9bf32 100644 --- a/git.py +++ b/git.py @@ -50,6 +50,7 @@ def isGitPatch(baseDir: str, nickname: str, domain: str, """Is the given post content a git patch? """ if messageType != 'Note' and \ + messageType != 'Page' and \ messageType != 'Patch': return False # must have a subject line diff --git a/posts.py b/posts.py index 347821b10..8c81ae68c 100644 --- a/posts.py +++ b/posts.py @@ -446,6 +446,7 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: return False if item['type'] != 'Create' and \ item['type'] != 'Announce' and \ + item['type'] != 'Page' and \ item['type'] != 'Note': if debug: print('Not a Create/Note/Announce type') @@ -465,7 +466,7 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: if debug: print('object is not a dict or string') return False - elif item['type'] == 'Note': + elif item['type'] == 'Note' or item['type'] == 'Page': if not item.get('published'): if debug: print('No published attribute') @@ -476,6 +477,10 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: thisItem = item['object'] # check that this is a public post # #Public should appear in the "to" list + itemIsNote = False + if item['type'] == 'Note' or item['type'] == 'Page': + itemIsNote = True + if isinstance(thisItem, dict): if thisItem.get('to'): isPublic = False @@ -485,7 +490,7 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: break if not isPublic: return False - elif isinstance(thisItem, str) or item['type'] == 'Note': + elif isinstance(thisItem, str) or itemIsNote: if item.get('to'): isPublic = False for recipient in item['to']: @@ -581,7 +586,7 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, continue thisItem = item - if item['type'] != 'Note': + if item['type'] != 'Note' and item['type'] != 'Page': thisItem = item['object'] content = getBaseContentFromPost(item, systemLanguage) @@ -3409,6 +3414,7 @@ def isImageMedia(session, baseDir: str, httpPrefix: str, if postJsonObject['object'].get('moderationStatus'): return False if postJsonObject['object']['type'] != 'Note' and \ + postJsonObject['object']['type'] != 'Page' and \ postJsonObject['object']['type'] != 'Event' and \ postJsonObject['object']['type'] != 'Article': return False @@ -4555,6 +4561,7 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str, recentPostsCache) return None if announcedJson['type'] != 'Note' and \ + announcedJson['type'] != 'Page' and \ announcedJson['type'] != 'Article': # You can only announce Note or Article types _rejectAnnounce(announceFilename, diff --git a/utils.py b/utils.py index 09eb9003b..5ac0351b6 100644 --- a/utils.py +++ b/utils.py @@ -2583,6 +2583,7 @@ def isDM(postJsonObject: {}) -> bool: if not hasObjectDict(postJsonObject): return False if postJsonObject['object']['type'] != 'Note' and \ + postJsonObject['object']['type'] != 'Page' and \ postJsonObject['object']['type'] != 'Patch' and \ postJsonObject['object']['type'] != 'EncryptedMessage' and \ postJsonObject['object']['type'] != 'Article': @@ -2611,6 +2612,7 @@ def isReply(postJsonObject: {}, actor: str) -> bool: if postJsonObject['object'].get('moderationStatus'): return False if postJsonObject['object']['type'] != 'Note' and \ + postJsonObject['object']['type'] != 'Page' and \ postJsonObject['object']['type'] != 'EncryptedMessage' and \ postJsonObject['object']['type'] != 'Article': return False diff --git a/webapp_profile.py b/webapp_profile.py index 807c996a4..a99e3380b 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -291,7 +291,7 @@ def htmlProfileAfterSearch(cssCache: {}, if not hasObjectDict(item): continue if item['type'] != 'Create' and item['type'] != 'Announce': - if item['type'] != 'Note': + if item['type'] != 'Note' and item['type'] != 'Page': continue if not item.get('to'): continue