@@ -191,20 +191,21 @@ func (c *GmailWatchStopCmd) Run(ctx context.Context, flags *RootFlags) error {
191191}
192192
193193type GmailWatchServeCmd struct {
194- Bind string `name:"bind" help:"Bind address" default:"127.0.0.1"`
195- Port int `name:"port" help:"Listen port" default:"8788"`
196- Path string `name:"path" help:"Push handler path" default:"/gmail-pubsub"`
197- Timezone string `name:"timezone" short:"z" help:"Output timezone (IANA name, e.g. America/New_York, UTC). Default: local"`
198- Local bool `name:"local" help:"Use local timezone (default behavior, useful to override --timezone)"`
199- VerifyOIDC bool `name:"verify-oidc" help:"Verify Pub/Sub OIDC tokens"`
200- OIDCEmail string `name:"oidc-email" help:"Expected service account email"`
201- OIDCAudience string `name:"oidc-audience" help:"Expected OIDC audience"`
202- SharedToken string `name:"token" help:"Shared token for x-gog-token or ?token="`
203- HookURL string `name:"hook-url" help:"Webhook URL to forward messages"`
204- HookToken string `name:"hook-token" help:"Webhook bearer token"`
205- IncludeBody bool `name:"include-body" help:"Include text/plain body in hook payload"`
206- MaxBytes int `name:"max-bytes" help:"Max bytes of body to include" default:"20000"`
207- SaveHook bool `name:"save-hook" help:"Persist hook settings to watch state"`
194+ Bind string `name:"bind" help:"Bind address" default:"127.0.0.1"`
195+ Port int `name:"port" help:"Listen port" default:"8788"`
196+ Path string `name:"path" help:"Push handler path" default:"/gmail-pubsub"`
197+ Timezone string `name:"timezone" short:"z" help:"Output timezone (IANA name, e.g. America/New_York, UTC). Default: local"`
198+ Local bool `name:"local" help:"Use local timezone (default behavior, useful to override --timezone)"`
199+ VerifyOIDC bool `name:"verify-oidc" help:"Verify Pub/Sub OIDC tokens"`
200+ OIDCEmail string `name:"oidc-email" help:"Expected service account email"`
201+ OIDCAudience string `name:"oidc-audience" help:"Expected OIDC audience"`
202+ SharedToken string `name:"token" help:"Shared token for x-gog-token or ?token="`
203+ HookURL string `name:"hook-url" help:"Webhook URL to forward messages"`
204+ HookToken string `name:"hook-token" help:"Webhook bearer token"`
205+ IncludeBody bool `name:"include-body" help:"Include text/plain body in hook payload"`
206+ MaxBytes int `name:"max-bytes" help:"Max bytes of body to include" default:"20000"`
207+ ExcludeLabels string `name:"exclude-labels" help:"Comma-separated list of Gmail label IDs to exclude from hook payload (e.g. SPAM,TRASH). Set to empty string to disable." default:"SPAM,TRASH"`
208+ SaveHook bool `name:"save-hook" help:"Persist hook settings to watch state"`
208209}
209210
210211func (c * GmailWatchServeCmd ) Run (ctx context.Context , kctx * kong.Context , flags * RootFlags ) error {
@@ -286,21 +287,23 @@ func (c *GmailWatchServeCmd) Run(ctx context.Context, kctx *kong.Context, flags
286287 }
287288
288289 cfg := gmailWatchServeConfig {
289- Account : account ,
290- Bind : c .Bind ,
291- Port : c .Port ,
292- Path : c .Path ,
293- VerifyOIDC : c .VerifyOIDC ,
294- OIDCEmail : c .OIDCEmail ,
295- OIDCAudience : c .OIDCAudience ,
296- SharedToken : c .SharedToken ,
297- HookTimeout : defaultHookRequestTimeoutSec * time .Second ,
298- HistoryMax : defaultHistoryMaxResults ,
299- ResyncMax : defaultHistoryResyncMax ,
300- AllowNoHook : hook == nil ,
301- IncludeBody : includeBody ,
302- MaxBodyBytes : maxBytes ,
303- DateLocation : loc ,
290+ Account : account ,
291+ Bind : c .Bind ,
292+ Port : c .Port ,
293+ Path : c .Path ,
294+ VerifyOIDC : c .VerifyOIDC ,
295+ OIDCEmail : c .OIDCEmail ,
296+ OIDCAudience : c .OIDCAudience ,
297+ SharedToken : c .SharedToken ,
298+ HookTimeout : defaultHookRequestTimeoutSec * time .Second ,
299+ HistoryMax : defaultHistoryMaxResults ,
300+ ResyncMax : defaultHistoryResyncMax ,
301+ AllowNoHook : hook == nil ,
302+ IncludeBody : includeBody ,
303+ MaxBodyBytes : maxBytes ,
304+ DateLocation : loc ,
305+ ExcludeLabels : splitCommaList (c .ExcludeLabels ),
306+ VerboseOutput : flags .Verbose ,
304307 }
305308 if hook != nil {
306309 cfg .HookURL = hook .URL
@@ -315,13 +318,14 @@ func (c *GmailWatchServeCmd) Run(ctx context.Context, kctx *kong.Context, flags
315318
316319 hookClient := & http.Client {Timeout : cfg .HookTimeout }
317320 server := & gmailWatchServer {
318- cfg : cfg ,
319- store : store ,
320- validator : validator ,
321- newService : newGmailService ,
322- hookClient : hookClient ,
323- logf : u .Err ().Printf ,
324- warnf : u .Err ().Printf ,
321+ cfg : cfg ,
322+ store : store ,
323+ validator : validator ,
324+ newService : newGmailService ,
325+ hookClient : hookClient ,
326+ excludeLabelIDs : lowerStringSet (cfg .ExcludeLabels ),
327+ logf : u .Err ().Printf ,
328+ warnf : u .Err ().Printf ,
325329 }
326330
327331 addr := net .JoinHostPort (c .Bind , strconv .Itoa (c .Port ))
0 commit comments