Move the task creation detection code above the comment detection code, and don't run the latter if the former is true.

pull/1/head
Simon Quigley 6 years ago
parent 643cec641d
commit 263d4ec192

@ -84,35 +84,37 @@ def main():
taskexists = False taskexists = False
if taskexists: if taskexists:
commentid = None # First, let's see if it's a new task
edited = False newcomment = False
# Let's see if this was a comment and if it's just an edit epoch = False
for task in tasksearch: for task in tasksearch:
dataepoch = data["action"]["epoch"] if epoch:
datemodified = task["dateModified"] if task["dateCreated"] == task["dateModified"] and task["dateCreated"] == epoch:
if datemodified >= (dataepoch - 10) and datemodified <= (dataepoch + 10) and task["comments"] != []: newcomment = True
comment = True
commentid = task["id"]
if datemodified != task["dateCreated"]:
edited = True
else: else:
edited = False newcomment = False
break break
else: else:
comment = False epoch = task["dateCreated"]
newcomment = False # If it's not a new task, let's see if it's a comment, and if it's just an edit
epoch = False if not newcomment:
if not comment and not edited: commentid = None
edited = False
for task in tasksearch: for task in tasksearch:
if epoch: dataepoch = data["action"]["epoch"]
if task["dateCreated"] == task["dateModified"] and task["dateCreated"] == epoch: datemodified = task["dateModified"]
newcomment = True if datemodified >= (dataepoch - 10) and datemodified <= (dataepoch + 10) and task["comments"] != []:
comment = True
commentid = task["id"]
if datemodified != task["dateCreated"]:
edited = True
else: else:
newcomment = False edited = False
break break
else: else:
epoch = task["dateCreated"] comment = False
# We should also know who did this thing # We should also know who did this thing
userlookup = tasksearch[0]["authorPHID"] userlookup = tasksearch[0]["authorPHID"]

Loading…
Cancel
Save