diff --git a/app/main.go b/app/main.go index 6f404353..e9008aeb 100644 --- a/app/main.go +++ b/app/main.go @@ -117,7 +117,7 @@ func main() { AvatarProxy: avatarProxy, }, Cache: rest.NewLoadingCache(4*time.Hour, 15*time.Minute, postFlushFn), - Notifier: notifier.NewNoperation(), + Notifier: notifier.NewNoOperation(), } if opts.DevMode { diff --git a/app/notifier/notifier.go b/app/notifier/notifier.go index f49ca647..1e0c753f 100644 --- a/app/notifier/notifier.go +++ b/app/notifier/notifier.go @@ -12,7 +12,7 @@ import ( type Interface interface { Subscribe(locator store.Locator, user store.User) error UnSubscribe(locator store.Locator, user store.User) error - OnUpdate(locator store.Locator) error + OnUpdate(comment store.Comment) error Status(locator store.Locator, user store.User) (bool, error) } @@ -22,13 +22,13 @@ type NoOperation struct { status map[string]struct{} } -// NewNoperation makes NoOperation fake notifier -func NewNoperation() *NoOperation { +// NewNoOperation makes NoOperation fake notifier +func NewNoOperation() *NoOperation { res := NoOperation{status: map[string]struct{}{}} return &res } -// Subscribe is a fake, just loging attempt +// Subscribe is a fake, just logging attempt func (n *NoOperation) Subscribe(locator store.Locator, user store.User) error { n.Lock() n.status[n.key(locator, user)] = struct{}{} @@ -37,7 +37,7 @@ func (n *NoOperation) Subscribe(locator store.Locator, user store.User) error { return nil } -// UnSubscribe is a fake, just loging attempt +// UnSubscribe is a fake, just logging attempt func (n *NoOperation) UnSubscribe(locator store.Locator, user store.User) error { n.Lock() delete(n.status, n.key(locator, user)) @@ -46,9 +46,9 @@ func (n *NoOperation) UnSubscribe(locator store.Locator, user store.User) error return nil } -// OnUpdate is a fake, just loging event -func (n *NoOperation) OnUpdate(locator store.Locator) error { - log.Printf("[DEBUG] update for %+v", locator) +// OnUpdate is a fake, just logging event +func (n *NoOperation) OnUpdate(comment store.Comment) error { + log.Printf("[DEBUG] update for %+v", comment) return nil } diff --git a/app/rest/server/rest.go b/app/rest/server/rest.go index 27cf057e..617cf13b 100644 --- a/app/rest/server/rest.go +++ b/app/rest/server/rest.go @@ -166,7 +166,7 @@ func (s *Rest) createCommentCtrl(w http.ResponseWriter, r *http.Request) { return } - if err = s.Notifier.OnUpdate(comment.Locator); err != nil { + if err = s.Notifier.OnUpdate(comment); err != nil { log.Printf("[WARN] can't send notify event for %+v, %s", comment.Locator, err) } diff --git a/app/rest/server/rest_test.go b/app/rest/server/rest_test.go index 873d3d33..ee085a95 100644 --- a/app/rest/server/rest_test.go +++ b/app/rest/server/rest_test.go @@ -351,7 +351,7 @@ func prep(t *testing.T) (srv *Rest, port int) { }, Exporter: &migrator.Remark{DataStore: dataStore}, Cache: &mockCache{}, - Notifier: notifier.NewNoperation(), + Notifier: notifier.NewNoOperation(), } go func() { port = rand.Intn(50000) + 1025