Add `NOTHING` action
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.
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.
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?
Updated in the master sheet to add "next action" field.
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.
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.
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
ThreadDatais 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))
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 bematchesAnyRule()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.
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.