diff --git a/server/server.go b/server/server.go index e2edfd4f..1540f41a 100644 --- a/server/server.go +++ b/server/server.go @@ -1328,6 +1328,7 @@ func (s *Server) execManager() { var subscribers int for _, t := range s.topics { subs := t.SubscribersCount() + log.Trace("- topic %s: %d subscribers", t.ID, subs) msgs, exists := messageCounts[t.ID] if subs == 0 && (!exists || msgs == 0) { log.Trace("Deleting empty topic %s", t.ID) diff --git a/server/server_account.go b/server/server_account.go index a08ed0bb..b56509f7 100644 --- a/server/server_account.go +++ b/server/server_account.go @@ -72,8 +72,8 @@ func (s *Server) handleAccountGet(w http.ResponseWriter, _ *http.Request, v *vis response.Role = string(v.user.Role) response.SyncTopic = v.user.SyncTopic if v.user.Prefs != nil { - if v.user.Prefs.Language != "" { - response.Language = v.user.Prefs.Language + if v.user.Prefs.Language != nil { + response.Language = *v.user.Prefs.Language } if v.user.Prefs.Notification != nil { response.Notification = v.user.Prefs.Notification @@ -210,20 +210,20 @@ func (s *Server) handleAccountSettingsChange(w http.ResponseWriter, r *http.Requ v.user.Prefs = &user.Prefs{} } prefs := v.user.Prefs - if newPrefs.Language != "" { + if newPrefs.Language != nil { prefs.Language = newPrefs.Language } if newPrefs.Notification != nil { if prefs.Notification == nil { prefs.Notification = &user.NotificationPrefs{} } - if newPrefs.Notification.DeleteAfter > 0 { + if newPrefs.Notification.DeleteAfter != nil { prefs.Notification.DeleteAfter = newPrefs.Notification.DeleteAfter } - if newPrefs.Notification.Sound != "" { + if newPrefs.Notification.Sound != nil { prefs.Notification.Sound = newPrefs.Notification.Sound } - if newPrefs.Notification.MinPriority > 0 { + if newPrefs.Notification.MinPriority != nil { prefs.Notification.MinPriority = newPrefs.Notification.MinPriority } } diff --git a/server/topic.go b/server/topic.go index 95a93c29..aacf6bea 100644 --- a/server/topic.go +++ b/server/topic.go @@ -64,7 +64,7 @@ func (t *topic) Publish(v *visitor, m *message) error { // we don't want individual slow subscribers to be able to block others. go func(s subscriber) { if err := s(v, m); err != nil { - log.Warn("%s Error forwarding to subscriber", logMessagePrefix(v, m)) + log.Warn("%s Error forwarding to subscriber: %s", logMessagePrefix(v, m), err.Error()) } }(s.subscriber) } diff --git a/user/types.go b/user/types.go index 14147c13..1d6f1c33 100644 --- a/user/types.go +++ b/user/types.go @@ -43,7 +43,7 @@ type Token struct { // Prefs represents a user's configuration settings type Prefs struct { - Language string `json:"language,omitempty"` + Language *string `json:"language,omitempty"` Notification *NotificationPrefs `json:"notification,omitempty"` Subscriptions []*Subscription `json:"subscriptions,omitempty"` } @@ -65,17 +65,17 @@ type Tier struct { // Subscription represents a user's topic subscription type Subscription struct { - ID string `json:"id"` - BaseURL string `json:"base_url"` - Topic string `json:"topic"` - DisplayName string `json:"display_name"` + ID string `json:"id"` + BaseURL string `json:"base_url"` + Topic string `json:"topic"` + DisplayName *string `json:"display_name"` } // NotificationPrefs represents the user's notification settings type NotificationPrefs struct { - Sound string `json:"sound,omitempty"` - MinPriority int `json:"min_priority,omitempty"` - DeleteAfter int `json:"delete_after,omitempty"` + Sound *string `json:"sound,omitempty"` + MinPriority *int `json:"min_priority,omitempty"` + DeleteAfter *int `json:"delete_after,omitempty"` } // Stats is a struct holding daily user statistics