Compare commits

...

2 Commits

Author SHA1 Message Date
46c308619e
Only update unread count when it has changed
All checks were successful
continuous-integration/drone/push Build is passing
2019-08-17 22:08:22 +02:00
53b4e748c3
Replace HPUT with HSET
HPUT is not a Redis command
2019-08-17 22:07:53 +02:00
2 changed files with 7 additions and 3 deletions

View File

@ -191,7 +191,7 @@ func (h *hubIncomingBackend) Feeds() ([]Feed, error) {
parts := strings.Split(feedKey, ":")
if len(parts) == 2 {
feed.ID, _ = strconv.ParseInt(parts[1], 10, 64)
_, err = conn.Do("HPUT", feedKey, "id", feed.ID)
_, err = conn.Do("HSET", feedKey, "id", feed.ID)
if err != nil {
log.Printf("could not save id for %s: %v", feedKey, err)
}
@ -208,7 +208,7 @@ func (h *hubIncomingBackend) Feeds() ([]Feed, error) {
}
feed.Callback = fmt.Sprintf("%s/incoming/%d", h.baseURL, feed.ID)
_, err = conn.Do("HPUT", feedKey, "callback", feed.Callback)
_, err = conn.Do("HSET", feedKey, "callback", feed.Callback)
if err != nil {
log.Printf("could not save id for %s: %v", feedKey, err)
}

View File

@ -661,10 +661,14 @@ func (b *memoryBackend) updateChannelUnreadCount(channel string) error {
return err
}
defer b.save()
currentCount := c.Unread.UnreadCount
c.Unread = microsub.Unread{Type: microsub.UnreadCount, UnreadCount: unread}
// Sent message to Server-Sent-Events
b.broker.Notifier <- sse.Message{Event: "new item in channel", Object: c}
if currentCount != unread {
b.broker.Notifier <- sse.Message{Event: "new item in channel", Object: c}
}
b.lock.Lock()
b.Channels[channel] = c