Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Unified Diff: filter/count/mail.go

Issue 1525923002: Implement Mail service. (Closed) Base URL: https://github.com/luci/gae.git@filter_user
Patch Set: tests and words Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « filter/count/count_test.go ('k') | filter/featureBreaker/mail.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/count/mail.go
diff --git a/filter/count/mail.go b/filter/count/mail.go
new file mode 100644
index 0000000000000000000000000000000000000000..01fc98691071e9a509c21663acfcf197214c67a6
--- /dev/null
+++ b/filter/count/mail.go
@@ -0,0 +1,44 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package count
+
+import (
+ "github.com/luci/gae/service/mail"
+ "golang.org/x/net/context"
+)
+
+// MailCounter is the counter object for the Mail service.
+type MailCounter struct {
+ Send Entry
+ SendToAdmins Entry
+}
+
+type mailCounter struct {
+ c *MailCounter
+
+ m mail.Interface
+}
+
+var _ mail.Interface = (*mailCounter)(nil)
+
+func (m *mailCounter) Send(msg *mail.Message) error {
+ return m.c.Send.up(m.m.Send(msg))
+}
+
+func (m *mailCounter) SendToAdmins(msg *mail.Message) error {
+ return m.c.SendToAdmins.up(m.m.SendToAdmins(msg))
+}
+
+func (m *mailCounter) Testable() mail.Testable {
+ return m.m.Testable()
+}
+
+// FilterMail installs a counter Mail filter in the context.
+func FilterMail(c context.Context) (context.Context, *MailCounter) {
+ state := &MailCounter{}
+ return mail.AddFilters(c, func(ic context.Context, u mail.Interface) mail.Interface {
+ return &mailCounter{state, u}
+ }), state
+}
« no previous file with comments | « filter/count/count_test.go ('k') | filter/featureBreaker/mail.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698