gmail-automata icon indicating copy to clipboard operation
gmail-automata copied to clipboard

Add `NOTHING` action

Open aaronj1335 opened this issue 5 years ago • 8 comments

This is a proposal for a change that allows you to leave the action column blank to signify that you want the rule to match messages and stop processing further rules, but not actually move the thread from its current state (similar to the current mark_important column behavior).

I'm having trouble correctly routing code review emails. I don't want CI messages for other people's changes to move threads to my inbox, but if I specify archive on those, and a CI message is processed in the same run as a relevant message, it overrides the relevant message. I could move the CI filter rule below, but that precludes a "catch-all" review rule to route uncategorized reviews to my inbox.

If this seems OK, let me know and I can add tests and make it a nicer thing.

aaronj1335 avatar Jun 16 '20 04:06 aaronj1335

So you have two rules, A targets CI message, B targets comment message. A has action ARCHIVE, B has action INBOX. I think you could move A before B (with lower row number in the sheet), and keep them in the same stage. So that the processing always tries to apply both, but B's action overrides A's action. Which means if you have both, the email will be in INBOX.

FYI, @dbarnett added feature "next action" in #16. But the column is not in the master sheet. You could give it a try to see if that helps.

ranmocy avatar Jun 18 '20 03:06 ranmocy

Totally, these more involved rule structures need some kind of chained logic, which sounds like the same set of problems I had in mind for "next action". FWIW, "no action" is still effectively "ARCHIVE" once the standard filter does its thing; I was bothered by the filter + GA moving things around too aggressively and losing state and discussed some of that in #9, but it's still a big unsolved problem.

@ranmocy We should go ahead and add it to master sheet, right? If not its own column then maybe some Note covering columns that are supported but not listed in a minimal quickstart sheet?

dbarnett avatar Jun 18 '20 07:06 dbarnett

Updated in the master sheet to add "next action" field.

ranmocy avatar Jun 25 '20 01:06 ranmocy

Hm, maybe I'm not understanding the "next action" thing, but I think it won't work since I specifically care about a new input in this case -- i.e. the current location of the thread:

  • If I get a message about a code review, then go do the review and archive the message, I don't want subsequent CI messages on that thread to move it from archive->inbox.
  • Conversely if I get a message about a code review, then a CI message, but I haven't done the review, I don't want to move it inbox->archive.

So in these 2 cases the ThreadData is the same, but there's currently no way to take a thread's current archive/inbox status into account.

aaronj1335 avatar Oct 14 '20 16:10 aaronj1335

FWIW, this is useful for me as I would like to use the script to only apply labels. I am not using the default filter rule to archive by default. There are some rules that the script currently cannot replicate, so I am using a combination of Gmail filters and this script to achieve my goals.

joech4n avatar Nov 09 '20 19:11 joech4n

Hm, maybe I'm not understanding the "next action" thing, but I think it won't work since I specifically care about a new input in this case -- i.e. the current location of the thread:

  • If I get a message about a code review, then go do the review and archive the message, I don't want subsequent CI messages on that thread to move it from archive->inbox.
  • Conversely if I get a message about a code review, then a CI message, but I haven't done the review, I don't want to move it inbox->archive.

So in these 2 cases the ThreadData is the same, but there's currently no way to take a thread's current archive/inbox status into account.

I think with PR #69 , you can now look at a thread's current archive/inbox status. I'm pretty sure, even though your Gmail filters send the incoming email to "Skip inbox", the thread stays where it is (from a recent test of mine). And with #69 you can do:

(or
  (thread is_in_inbox)
  (thread is_starred))

mlsad3 avatar Aug 10 '22 04:08 mlsad3

I keep thinking on this and I think the gist is that If there is a rule (row in Sheet) that has not specified to do anything, then don't do anything and finish the stage. I think this can maybe be done differently by:

  • Update the hasAnyAction() to be matchesAnyRule() instead

Otherwise we should have added a hasAnyAction() check when we process the rules, and let the user know they have rows with no actions in them (instead of waiting until a message hits that particular row, and then throwing the error). I didn't know it was not allowed until recently. I just assumed if you had no actions specified that it would just allow the rule to match and finish processing the email.

mlsad3 avatar Aug 10 '22 13:08 mlsad3

I agree the label checks are another way to get this information. The downside is it seems like a pain to read something like:

# Row 1
(and (label "inbox") (sender "[email protected]")) # move to inbox
# Row 2
(and (not (label "inbox")) (sender "[email protected]")) # archive

Instead of having one row with an empty action (@mlsad3 maybe this is what you're getting at in your last comment).


On a side note, this one has also been a bit of a pain to continuously rebase over the years, so if it's not something you're up for merging @ranmocy , that's completely understandable, but it'd be helpful to know that I'll indefinitely have a fork of this repo.

aaronj1335 avatar Aug 12 '22 20:08 aaronj1335