From a70ca0f0d0602c2461316935c432b6f44cb1fe18 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 13:22:47 +0100 Subject: [PATCH 01/21] More grammatical --- posts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts.py b/posts.py index 80711aa6d..cb9975957 100644 --- a/posts.py +++ b/posts.py @@ -446,7 +446,7 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: return False if item['type'] != 'Create' and item['type'] != 'Announce': if debug: - print('Not Create type') + print('Not a Create type') return False if item.get('object'): if isinstance(item['object'], dict): From aaa201ba9aeb88bee4ad035ac19f090329412177 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 13:46:38 +0100 Subject: [PATCH 02/21] Resolve posts from Friendica --- posts.py | 60 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/posts.py b/posts.py index cb9975957..ee09d8991 100644 --- a/posts.py +++ b/posts.py @@ -444,9 +444,11 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: if debug: print('No type') return False - if item['type'] != 'Create' and item['type'] != 'Announce': + if item['type'] != 'Create' and \ + item['type'] != 'Announce' and \ + item['type'] != 'Note': if debug: - print('Not a Create type') + print('Not a Create/Note/Announce type') return False if item.get('object'): if isinstance(item['object'], dict): @@ -463,19 +465,27 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool: if debug: print('object is not a dict or string') return False + elif item['type'] == 'Note': + if not item.get('published'): + if debug: + print('No published attribute') + return False if not personPosts.get(item['id']): + thisItem = item + if item.get('object'): + thisItem = item['object'] # check that this is a public post # #Public should appear in the "to" list - if isinstance(item['object'], dict): - if item['object'].get('to'): + if isinstance(thisItem, dict): + if thisItem.get('to'): isPublic = False - for recipient in item['object']['to']: + for recipient in thisItem['to']: if recipient.endswith('#Public'): isPublic = True break if not isPublic: return False - elif isinstance(item['object'], str): + elif isinstance(thisItem, str) or item['type'] == 'Note': if item.get('to'): isPublic = False for recipient in item['to']: @@ -570,6 +580,10 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, if not _isPublicFeedPost(item, personPosts, debug): continue + thisItem = item + if item['type'] != 'Note': + thisItem = item['object'] + content = getBaseContentFromPost(item, systemLanguage) content = content.replace(''', "'") @@ -579,9 +593,9 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, inReplyTo = '' attachment = [] sensitive = False - if isinstance(item['object'], dict): - if item['object'].get('tag'): - for tagItem in item['object']['tag']: + if isinstance(thisItem, dict): + if thisItem.get('tag'): + for tagItem in thisItem['tag']: tagType = tagItem['type'].lower() if tagType == 'emoji': if tagItem.get('name') and tagItem.get('icon'): @@ -609,25 +623,25 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, print('max emojis reached') continue - if item['object'].get('summary'): - if item['object']['summary']: - summary = item['object']['summary'] + if thisItem.get('summary'): + if thisItem['summary']: + summary = thisItem['summary'] - if item['object'].get('inReplyTo'): - if item['object']['inReplyTo']: - if isinstance(item['object']['inReplyTo'], str): + if thisItem.get('inReplyTo'): + if thisItem['inReplyTo']: + if isinstance(thisItem['inReplyTo'], str): # No replies to non-permitted domains - if not urlPermitted(item['object']['inReplyTo'], + if not urlPermitted(thisItem['inReplyTo'], federationList): if debug: print('url not permitted ' + - item['object']['inReplyTo']) + thisItem['inReplyTo']) continue - inReplyTo = item['object']['inReplyTo'] + inReplyTo = thisItem['inReplyTo'] - if item['object'].get('attachment'): - if item['object']['attachment']: - for attach in item['object']['attachment']: + if thisItem.get('attachment'): + if thisItem['attachment']: + for attach in thisItem['attachment']: if attach.get('name') and attach.get('url'): # no attachments from non-permitted domains if urlPermitted(attach['url'], @@ -640,8 +654,8 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, attach['url']) sensitive = False - if item['object'].get('sensitive'): - sensitive = item['object']['sensitive'] + if thisItem.get('sensitive'): + sensitive = thisItem['sensitive'] if content: if simple: From a19d5a58653e8585e29a1bc1532b4017e55550cc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 14:06:52 +0100 Subject: [PATCH 03/21] Show Friendica timeline after search on handle --- webapp_profile.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/webapp_profile.py b/webapp_profile.py index 1f29a368d..8a4c188d9 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -283,16 +283,31 @@ def htmlProfileAfterSearch(cssCache: {}, if isCreateInsideAnnounce(item): isAnnouncedFeedItem = True item = item['object'] - if not item.get('actor'): - continue - if not isAnnouncedFeedItem and item['actor'] != personUrl: - continue if not item.get('type'): continue if item['type'] == 'Create': if not hasObjectDict(item): continue if item['type'] != 'Create' and item['type'] != 'Announce': + if item['type'] != 'Note': + continue + if not item.get('to'): + continue + # wrap in create + cc = [] + if item.get('cc'): + cc = item['cc'] + newItem = { + 'object': item, + 'to': item['to'], + 'cc': cc, + 'actor': personUrl, + 'type': 'Create' + } + item = newItem + if not item.get('actor'): + continue + if not isAnnouncedFeedItem and item['actor'] != personUrl: continue profileStr += \ From cfa09310a05a5481961fe6af01b1b89960dbad85 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 14:10:47 +0100 Subject: [PATCH 04/21] Add id to create --- webapp_profile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webapp_profile.py b/webapp_profile.py index 8a4c188d9..34d1646c2 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -293,6 +293,8 @@ def htmlProfileAfterSearch(cssCache: {}, continue if not item.get('to'): continue + if not item.get('id'): + continue # wrap in create cc = [] if item.get('cc'): @@ -301,6 +303,7 @@ def htmlProfileAfterSearch(cssCache: {}, 'object': item, 'to': item['to'], 'cc': cc, + 'id': item['id'], 'actor': personUrl, 'type': 'Create' } From 1761c24bed529028bb14c2a828875af46058442e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 16:10:18 +0100 Subject: [PATCH 05/21] Check that tags have a type --- posts.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/posts.py b/posts.py index ee09d8991..587d805e2 100644 --- a/posts.py +++ b/posts.py @@ -596,6 +596,8 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, if isinstance(thisItem, dict): if thisItem.get('tag'): for tagItem in thisItem['tag']: + if not tagItem.get('type'): + continue tagType = tagItem['type'].lower() if tagType == 'emoji': if tagItem.get('name') and tagItem.get('icon'): @@ -787,6 +789,8 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int, if item['object'].get('tag'): for tagItem in item['object']['tag']: + if not tagItem.get('type'): + continue tagType = tagItem['type'].lower() if tagType == 'mention': if tagItem.get('href'): @@ -855,6 +859,8 @@ def _getPostsForBlockedDomains(baseDir: str, if item['object'].get('tag'): for tagItem in item['object']['tag']: + if not tagItem.get('type'): + continue tagType = tagItem['type'].lower() if tagType == 'mention': if tagItem.get('href'): From 0ec2c45b509a990a5e10aa20402b78100ccc2fe2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 20:38:35 +0100 Subject: [PATCH 06/21] Less indentation --- posts.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/posts.py b/posts.py index 587d805e2..ea5b5bb82 100644 --- a/posts.py +++ b/posts.py @@ -862,20 +862,19 @@ def _getPostsForBlockedDomains(baseDir: str, if not tagItem.get('type'): continue tagType = tagItem['type'].lower() - if tagType == 'mention': - if tagItem.get('href'): - postDomain, postPort = \ - getDomainFromActor(tagItem['href']) - if isBlockedDomain(baseDir, postDomain): - if item['object'].get('url'): - url = item['object']['url'] - else: - url = item['object']['id'] - if not blockedPosts.get(postDomain): - blockedPosts[postDomain] = [url] - else: - if url not in blockedPosts[postDomain]: - blockedPosts[postDomain].append(url) + if tagType == 'mention' and tagItem.get('href'): + postDomain, postPort = \ + getDomainFromActor(tagItem['href']) + if isBlockedDomain(baseDir, postDomain): + if item['object'].get('url'): + url = item['object']['url'] + else: + url = item['object']['id'] + if not blockedPosts.get(postDomain): + blockedPosts[postDomain] = [url] + else: + if url not in blockedPosts[postDomain]: + blockedPosts[postDomain].append(url) return blockedPosts From 7cd0d969b52951200d4598df64cbcb7d09e9f425 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 21:08:21 +0100 Subject: [PATCH 07/21] If actor is unexpected then check cc field when showing timeline for searched handle --- webapp_profile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp_profile.py b/webapp_profile.py index 34d1646c2..8c9f28555 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -311,7 +311,13 @@ def htmlProfileAfterSearch(cssCache: {}, if not item.get('actor'): continue if not isAnnouncedFeedItem and item['actor'] != personUrl: - continue + # if the actor is different then check the cc field + if not item.get('cc'): + continue + if not isinstance(item['cc'], list): + continue + if personUrl not in item['cc']: + continue profileStr += \ individualPostAsHtml(signingPrivateKeyPem, From 6716ebfe78cc14d94272bc115ad0b9fb4d32f1bb Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 21:20:37 +0100 Subject: [PATCH 08/21] Switch actor with cc if needed --- webapp_profile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webapp_profile.py b/webapp_profile.py index 8c9f28555..d1518456b 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -318,6 +318,11 @@ def htmlProfileAfterSearch(cssCache: {}, continue if personUrl not in item['cc']: continue + # switch actor with cc + item['actor'] = item['cc'] + item['object']['actor'] = item['cc'] + item['cc'] = [] + item['object']['cc'] = [] profileStr += \ individualPostAsHtml(signingPrivateKeyPem, From fd9ae03a1a435e3076f7fa21436df4173439fe1a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 21:26:34 +0100 Subject: [PATCH 09/21] Revert to original --- webapp_profile.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/webapp_profile.py b/webapp_profile.py index d1518456b..34d1646c2 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -311,18 +311,7 @@ def htmlProfileAfterSearch(cssCache: {}, if not item.get('actor'): continue if not isAnnouncedFeedItem and item['actor'] != personUrl: - # if the actor is different then check the cc field - if not item.get('cc'): - continue - if not isinstance(item['cc'], list): - continue - if personUrl not in item['cc']: - continue - # switch actor with cc - item['actor'] = item['cc'] - item['object']['actor'] = item['cc'] - item['cc'] = [] - item['object']['cc'] = [] + continue profileStr += \ individualPostAsHtml(signingPrivateKeyPem, From c18bd9c0f23fcf6eb048d315fbf8e7c4d9601939 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 27 Oct 2021 23:05:44 +0100 Subject: [PATCH 10/21] Tidying --- inbox.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/inbox.py b/inbox.py index deac45910..a5bc093a5 100644 --- a/inbox.py +++ b/inbox.py @@ -3204,8 +3204,7 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool): baseDir + '/accounts/unknownContexts.txt' unknownContext = str(originalJson['@context']) - print('unrecognized @context: ' + - unknownContext) + print('unrecognized @context: ' + unknownContext) alreadyUnknown = False if os.path.isfile(unknownContextsFile): @@ -3217,8 +3216,7 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool): with open(unknownContextsFile, 'a+') as unknownFile: unknownFile.write(unknownContext + '\n') else: - print('Unrecognized jsonld signature type: ' + - jwebsigType) + print('Unrecognized jsonld signature type: ' + jwebsigType) unknownSignaturesFile = \ baseDir + '/accounts/unknownJsonSignatures.txt' From 4f17e93a02b345c8519d3444ac414fa63e5ee339 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 10:33:27 +0100 Subject: [PATCH 11/21] Avatar property of webfinger --- webfinger.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webfinger.py b/webfinger.py index 3ca4f00e5..c2aa75358 100644 --- a/webfinger.py +++ b/webfinger.py @@ -159,12 +159,18 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int, profilePageHref = httpPrefix + '://' + domain + \ '/about/more?instance_actor=true' + avatarUrl = httpPrefix + "://" + domain + "/@" + personName + "/avatar.png" account = { "aliases": [ httpPrefix + "://" + domain + "/@" + personName, personId ], "links": [ + { + "href": avatarUrl, + "rel": "http://webfinger.net/rel/avatar", + "type": "image/png" + }, { "href": profilePageHref, "rel": "http://webfinger.net/rel/profile-page", From f85a8073216846f96cb1cdb906f59a449be51baf Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 10:34:11 +0100 Subject: [PATCH 12/21] Tidying --- webfinger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webfinger.py b/webfinger.py index c2aa75358..c7a616508 100644 --- a/webfinger.py +++ b/webfinger.py @@ -159,10 +159,11 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int, profilePageHref = httpPrefix + '://' + domain + \ '/about/more?instance_actor=true' - avatarUrl = httpPrefix + "://" + domain + "/@" + personName + "/avatar.png" + personLink = httpPrefix + "://" + domain + "/@" + personName + avatarUrl = personLink + "/avatar.png" account = { "aliases": [ - httpPrefix + "://" + domain + "/@" + personName, + personLink, personId ], "links": [ From 8995291a7caf61c2d99b7104751763d10876cb9d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 10:41:18 +0100 Subject: [PATCH 13/21] Link to blog within webfinger --- webfinger.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webfinger.py b/webfinger.py index c7a616508..b54072780 100644 --- a/webfinger.py +++ b/webfinger.py @@ -168,10 +168,14 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int, ], "links": [ { - "href": avatarUrl, + "href": personLink + "/avatar.png", "rel": "http://webfinger.net/rel/avatar", "type": "image/png" }, + { + "href": httpPrefix + "://" + domain + "/blog/" + personName, + "rel": "http://webfinger.net/rel/blog" + }, { "href": profilePageHref, "rel": "http://webfinger.net/rel/profile-page", From 5df6f916df457e5812ea7c648922ab52f1a74cd6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 11:08:41 +0100 Subject: [PATCH 14/21] Update avatar image within webfinger if it changes --- webfinger.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/webfinger.py b/webfinger.py index b54072780..ed62552b5 100644 --- a/webfinger.py +++ b/webfinger.py @@ -160,7 +160,6 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int, '/about/more?instance_actor=true' personLink = httpPrefix + "://" + domain + "/@" + personName - avatarUrl = personLink + "/avatar.png" account = { "aliases": [ personLink, @@ -294,6 +293,33 @@ def webfingerLookup(path: str, baseDir: str, return wfJson +def _webfingerUpdateAvatar(wfJson: {}, actorJson: {}) -> bool: + """Updates the avatar image link + """ + found = False + avatarUrl = actorJson['icon']['url'] + mediaType = actorJson['icon']['mediaType'] + for link in wfJson['links']: + if not link.get('rel'): + continue + if not link['rel'].endswith('://webfinger.net/rel/avatar'): + continue + found = True + if link['href'] != avatarUrl or link['type'] != mediaType: + link['href'] = avatarUrl + link['type'] = mediaType + return True + break + if found: + return False + wfJson['links'].append({ + "href": avatarUrl, + "rel": "http://webfinger.net/rel/avatar", + "type": mediaType + }) + return True + + def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool: """Updates webfinger Email/blog/xmpp links from profile Returns true if one or more tags has been changed @@ -368,6 +394,9 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool: wfJson['aliases'].remove(fullAlias) changed = True + if _webfingerUpdateAvatar(wfJson, actorJson): + changed = True + return changed From eee33cdb328d8664a975e0008e8b17aa1c32cf99 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 11:21:28 +0100 Subject: [PATCH 15/21] Add blog link to webfinger if needed --- webfinger.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/webfinger.py b/webfinger.py index ed62552b5..9eabeeaec 100644 --- a/webfinger.py +++ b/webfinger.py @@ -320,6 +320,37 @@ def _webfingerUpdateAvatar(wfJson: {}, actorJson: {}) -> bool: return True +def _webfingerAddBlogLink(wfJson: {}, actorJson: {}) -> bool: + """Adds a blog link to webfinger if needed + """ + found = False + if '/users/' in actorJson['id']: + blogUrl = \ + actorJson['id'].split('/users/')[0] + '/blog/' + \ + actorJson['id'].split('/users/')[1] + else: + blogUrl = \ + actorJson['id'].split('/@')[0] + '/blog/' + \ + actorJson['id'].split('/@')[1] + for link in wfJson['links']: + if not link.get('rel'): + continue + if not link['rel'].endswith('://webfinger.net/rel/blog'): + continue + found = True + if link['href'] != blogUrl: + link['href'] = blogUrl + return True + break + if found: + return False + wfJson['links'].append({ + "href": blogUrl, + "rel": "http://webfinger.net/rel/blog" + }) + return True + + def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool: """Updates webfinger Email/blog/xmpp links from profile Returns true if one or more tags has been changed @@ -397,6 +428,9 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool: if _webfingerUpdateAvatar(wfJson, actorJson): changed = True + if _webfingerAddBlogLink(wfJson, actorJson): + changed = True + return changed From cbb76eb97b8f55dd9dfa60fa55336397b13bae83 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 12:20:56 +0100 Subject: [PATCH 16/21] Parsing edit blog post link --- daemon.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon.py b/daemon.py index e95d82273..a732b789e 100644 --- a/daemon.py +++ b/daemon.py @@ -14402,13 +14402,13 @@ class PubServer(BaseHTTPRequestHandler): if authorized and \ '/users/' in self.path and \ '?editblogpost=' in self.path and \ - '?actor=' in self.path: + ';actor=' in self.path: messageId = self.path.split('?editblogpost=')[1] if '?' in messageId: messageId = messageId.split('?')[0] - actor = self.path.split('?actor=')[1] - if '?' in actor: - actor = actor.split('?')[0] + actor = self.path.split(';actor=')[1] + if ';' in actor: + actor = actor.split(';')[0] nickname = getNicknameFromActor(self.path.split('?')[0]) if nickname == actor: postUrl = \ From 3024bd77d3e9a1d932446a76bee97ddcdcba95af Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 12:22:08 +0100 Subject: [PATCH 17/21] Semicolon separator --- daemon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon.py b/daemon.py index a732b789e..a011f230f 100644 --- a/daemon.py +++ b/daemon.py @@ -14404,8 +14404,8 @@ class PubServer(BaseHTTPRequestHandler): '?editblogpost=' in self.path and \ ';actor=' in self.path: messageId = self.path.split('?editblogpost=')[1] - if '?' in messageId: - messageId = messageId.split('?')[0] + if ';' in messageId: + messageId = messageId.split(';')[0] actor = self.path.split(';actor=')[1] if ';' in actor: actor = actor.split(';')[0] From 6f2b02f369ceae7c5f1fababa47f9cffb97b20c0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 12:48:05 +0100 Subject: [PATCH 18/21] Check for malformed ciphertext within incoming posts --- daemon.py | 8 +++++++- utils.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index a011f230f..fa3107728 100644 --- a/daemon.py +++ b/daemon.py @@ -237,6 +237,7 @@ from categories import updateHashtagCategories from languages import getActorLanguages from languages import setActorLanguages from like import updateLikesCollection +from utils import malformedCiphertext from utils import hasActor from utils import setReplyIntervalHours from utils import canReplyTo @@ -1490,10 +1491,15 @@ class PubServer(BaseHTTPRequestHandler): # save the json for later queue processing messageBytesDecoded = messageBytes.decode('utf-8') + if malformedCiphertext(messageBytesDecoded): + print('WARN: post contains malformed ciphertext ' + + str(originalMessageJson)) + return 4 + if containsInvalidLocalLinks(messageBytesDecoded): print('WARN: post contains invalid local links ' + str(originalMessageJson)) - return 4 + return 5 self.server.blockedCacheLastUpdated = \ updateBlockedCache(self.server.baseDir, diff --git a/utils.py b/utils.py index 45e6e4152..ed55ceb06 100644 --- a/utils.py +++ b/utils.py @@ -2537,6 +2537,16 @@ def isPGPEncrypted(content: str) -> bool: return False +def malformedCiphertext(content: str) -> bool: + """Returns true if the given content contains a malformed key + """ + if '----BEGIN ' in content or '----END ' in content: + if not containsPGPPublicKey(content) and \ + not isPGPEncrypted(content): + return True + return False + + def loadTranslationsFromFile(baseDir: str, language: str) -> ({}, str): """Returns the translations dictionary """ From 605395ba5e922fb2d85a8a9bab42edd7ab1e1f1c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 14:27:25 +0100 Subject: [PATCH 19/21] Debug --- webfinger.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webfinger.py b/webfinger.py index 9eabeeaec..bf3768c43 100644 --- a/webfinger.py +++ b/webfinger.py @@ -252,8 +252,7 @@ def webfingerLookup(path: str, baseDir: str, return None if '&' in handle: handle = handle.split('&')[0].strip() - if debug: - print('DEBUG: WEBFINGER handle with & removed ' + handle) + print('DEBUG: WEBFINGER handle with & removed ' + handle) if '@' not in handle: if debug: print('DEBUG: WEBFINGER no @ in handle ' + handle) From 63a94cdae8c9fe6512998ac123c9592c05792d5a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 16:59:23 +0100 Subject: [PATCH 20/21] Add an update timestamp to actor after changes This is what Roadhouse does, and it's vaguely indicated in the AP spec --- daemon.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/daemon.py b/daemon.py index fa3107728..d132be927 100644 --- a/daemon.py +++ b/daemon.py @@ -5874,6 +5874,11 @@ class PubServer(BaseHTTPRequestHandler): actorJson['featuredTags'] = \ actorJson['id'] + '/collections/tags' randomizeActorImages(actorJson) + # add an updated timestamp to the actor + updatedTime = datetime.datetime.utcnow() + actorJson['updated'] = \ + updatedTime.strftime("%Y-%m-%dT%H:%M:%SZ") + # save the actor saveJson(actorJson, actorFilename) webfingerUpdate(baseDir, nickname, domain, From 1f073d47450b888acd451cc801549336b3af6cee Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 28 Oct 2021 17:13:22 +0100 Subject: [PATCH 21/21] Add updated fields to avatar and banner when actor is changed --- daemon.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daemon.py b/daemon.py index d132be927..13369fb8d 100644 --- a/daemon.py +++ b/daemon.py @@ -5878,6 +5878,9 @@ class PubServer(BaseHTTPRequestHandler): updatedTime = datetime.datetime.utcnow() actorJson['updated'] = \ updatedTime.strftime("%Y-%m-%dT%H:%M:%SZ") + # add updated timestamp to avatar and banner + actorJson['icon']['updated'] = actorJson['updated'] + actorJson['image']['updated'] = actorJson['updated'] # save the actor saveJson(actorJson, actorFilename) webfingerUpdate(baseDir,