From 9510ac8bf851ff39a743c26b9ff43a3f90e6c58b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 22 Jun 2021 20:43:03 +0100 Subject: [PATCH] Equality check --- announce.py | 36 ++++++++++++++++++------------------ outbox.py | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/announce.py b/announce.py index 0d61efb8a..1660827e6 100644 --- a/announce.py +++ b/announce.py @@ -27,6 +27,24 @@ from webfinger import webfingerHandle from auth import createBasicAuthHeader +def isSelfAnnounce(postJsonObject: {}) -> bool: + """Is the given post a self announce? + """ + if not postJsonObject.get('actor'): + return False + if not postJsonObject.get('type'): + return False + if postJsonObject['type'] != 'Announce': + return False + if not postJsonObject.get('object'): + return False + if not isinstance(postJsonObject['actor'], str): + return False + if not isinstance(postJsonObject['object'], str): + return False + return postJsonObject['actor'] in postJsonObject['object'] + + def outboxAnnounce(recentPostsCache: {}, baseDir: str, messageJson: {}, debug: bool) -> bool: """ Adds or removes announce entries from the shares collection @@ -393,21 +411,3 @@ def outboxUndoAnnounce(recentPostsCache: {}, messageJson['actor'], domain, debug) if debug: print('DEBUG: post undo announce via c2s - ' + postFilename) - - -def isSelfAnnounce(postJsonObject: {}) -> bool: - """Is the given post a self announce? - """ - if not postJsonObject.get('actor'): - return False - if not postJsonObject.get('type'): - return False - if postJsonObject['type'] != 'Announce': - return False - if not postJsonObject.get('object'): - return False - if not isinstance(postJsonObject['actor'], str): - return False - if not isinstance(postJsonObject['object'], str): - return False - return postJsonObject['actor'] in postJsonObject['object'] diff --git a/outbox.py b/outbox.py index dae0e8be8..bf2e21cea 100644 --- a/outbox.py +++ b/outbox.py @@ -402,7 +402,7 @@ def postMessageToOutbox(session, translate: {}, continue # avoid duplicates of the message if already going # back to the inbox of the same account - if selfActor not in messageJson['to']: + if messageJson['to'] != selfActor: # show sent post within the inbox, # as is the typical convention inboxUpdateIndex(boxNameIndex, baseDir,