From 171f23e751d6b6e384a74f6fbd3f8e852dd65c35 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 9 Nov 2019 13:06:38 +0000 Subject: [PATCH] dms are not necessarily replies --- posts.py | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/posts.py b/posts.py index bb484d6e..f14765ea 100644 --- a/posts.py +++ b/posts.py @@ -1894,29 +1894,34 @@ def isImageMedia(session,baseDir: str,httpPrefix: str,nickname: str,domain: str, def isReply(postJsonObject: {},actor: str) -> bool: """Returns true if the given post is a reply to the given actor """ - if postJsonObject['type']!='Create': - return False - if not postJsonObject.get('object'): - return False - if not isinstance(postJsonObject['object'], dict): - return False - if postJsonObject['object']['type']!='Note': - return False - if postJsonObject['object'].get('inReplyTo'): - if postJsonObject['object']['inReplyTo'].startswith(actor): - return True - if not postJsonObject['object'].get('tag'): - return False - if not isinstance(postJsonObject['object']['tag'], list): - return False - for tag in postJsonObject['object']['tag']: - if not tag.get('type'): - continue - if tag['type']=='Mention': - if not tag.get('href'): + if isDM(postJsonObject): + if postJsonObject['object'].get('inReplyTo'): + if postJsonObject['object']['inReplyTo'].startswith(actor): + return True + else: + if postJsonObject['type']!='Create': + return False + if not postJsonObject.get('object'): + return False + if not isinstance(postJsonObject['object'], dict): + return False + if postJsonObject['object']['type']!='Note': + return False + if postJsonObject['object'].get('inReplyTo'): + if postJsonObject['object']['inReplyTo'].startswith(actor): + return True + if not postJsonObject['object'].get('tag'): + return False + if not isinstance(postJsonObject['object']['tag'], list): + return False + for tag in postJsonObject['object']['tag']: + if not tag.get('type'): continue - if actor in tag['href']: - return True + if tag['type']=='Mention': + if not tag.get('href'): + continue + if actor in tag['href']: + return True return False def createBoxIndex(boxDir: str,postsInBoxDict: {}) -> int: