pass comment of notify event

This commit is contained in:
Umputun
2018-02-16 12:39:41 -06:00
parent 644b17de10
commit 01f61f8fbd
4 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -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 {
+8 -8
View File
@@ -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
}
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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