Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunking supported? #158

Closed
skyzyx opened this issue Dec 27, 2020 · 6 comments · Fixed by #165
Closed

Chunking supported? #158

skyzyx opened this issue Dec 27, 2020 · 6 comments · Fixed by #165
Labels
kind/feature New feature or request lifecycle/keep-alive Denotes an issues or PR that should never be considered stale.

Comments

@skyzyx
Copy link

skyzyx commented Dec 27, 2020

I have very long lists of {from: …} blocks. The longest one is over 200 entries. While the Gmail API accepts this, clicking on edit in the UI (so that I can apply to existing emails) presents an alert that the rule is too long.

Is there a way to chunk the list? For example, in chunks of 75. 200 entries in chunks of 75 would create three rules with entries:

  • 1–75
  • 76–150
  • 150–200

This would simplify maintenance so that I could keep the one long list, but the software (or configuration) can deal with chunking across multiple rules.

@mbrt
Copy link
Owner

mbrt commented Dec 27, 2020

Good point that this should be supported natively. It was on my mind already, as it doesn't seem hard to do but I never actually implemented it.

@mbrt mbrt added kind/feature New feature or request lifecycle/keep-alive Denotes an issues or PR that should never be considered stale. labels Dec 27, 2020
@mbrt
Copy link
Owner

mbrt commented Jan 27, 2021

PR #165 should be the solution for this problem. It can split a couple of filter types:

  • Simple OR like list:{l1 l2 .... ln}
  • More complex AND of ORs (e.g. (list:{l1 l2 ... ln} -to:foo)

These two cases are split into multiple filters in chunks of 20 operators. The limit is pretty arbitrary, but it should be small enough to work and big enough to go unnoticed to users with filters that worked so far.

@skyzyx Let me know if this works for you.

@mbrt mbrt closed this as completed in #165 Jan 27, 2021
@skyzyx
Copy link
Author

skyzyx commented Jan 28, 2021

Thank you. Happy to try it out shortly! 👍🏻

@skyzyx
Copy link
Author

skyzyx commented Feb 1, 2021

I didn't see build instructions in the README, nor did I see a CONTRIBUTING guide. But I did find cmd/gmailctl/main.go, so I guessed that I could do something like:

mkdir -p bin
cd cmd/gmailctl
go build -o ../../bin/ ./...
cd ../../
bin/gmailctl --help

It appears to have worked. At least — it shows me the help text.

But after running bin/gmailctl edit and updating the text, saving gives me the following error:

Error applying configuration: getting filters from Gmail: Get "https://gmail.googleapis.com/gmail/v1/users/me/labels?alt=json&prettyPrint=false": oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error": "invalid_grant",
  "error_description": "Bad Request"
}
Do you want to continue editing? [y/N]: n

I hadn't changed anything since I first set this up with the latest release. Re-running bin/gmailctl init says that everything is good.

Did I miss an upgrade step somewhere?

@mbrt
Copy link
Owner

mbrt commented Feb 1, 2021

For building the binary from sources:

cd root/of/the/repo
go build ./cmd/gmailctl

This is the standard way of building a Go binary. Good point that there's no mention of it anywhere though.

Regarding the API error, if my memory doesn't fail me, it could be because you changed the password or invalidated the token in some other way. You can try resetting it:

gmailctl init --reset
gmailctl init

@skyzyx
Copy link
Author

skyzyx commented Feb 2, 2021

I've actually run into some weird, esoteric issues when running go build from a non-source directory. But hey. :)

Fixing my credentials resolved the issue. Thanks!

Feature appears to work wonderfully. Makes managing these long lists of domains much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request lifecycle/keep-alive Denotes an issues or PR that should never be considered stale.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants