+
# Duration for which messages will be buffered before they are deleted.
# This is required to support the "since=..." and "poll=1" parameter.
#
-# message-buffer-duration: 12h
+# cache-duration: 12h
# Interval in which keepalive messages are sent to the client. This is to prevent
# intermediaries closing the connection for inactivity.
diff --git a/server/cache_mem.go b/server/cache_mem.go
index 1e7e08d6..6c3a94f1 100644
--- a/server/cache_mem.go
+++ b/server/cache_mem.go
@@ -7,8 +7,8 @@ import (
)
type memCache struct {
- messages map[string][]*message
- mu sync.Mutex
+ messages map[string][]*message
+ mu sync.Mutex
}
var _ cache = (*memCache)(nil)
diff --git a/server/cache_sqlite.go b/server/cache_sqlite.go
index 6f041f16..2a07f741 100644
--- a/server/cache_sqlite.go
+++ b/server/cache_sqlite.go
@@ -19,8 +19,8 @@ const (
CREATE INDEX IF NOT EXISTS idx_topic ON messages (topic);
COMMIT;
`
- insertMessageQuery = `INSERT INTO messages (id, time, topic, message) VALUES (?, ?, ?, ?)`
- pruneMessagesQuery = `DELETE FROM messages WHERE time < ?`
+ insertMessageQuery = `INSERT INTO messages (id, time, topic, message) VALUES (?, ?, ?, ?)`
+ pruneMessagesQuery = `DELETE FROM messages WHERE time < ?`
selectMessagesSinceTimeQuery = `
SELECT id, time, message
FROM messages
@@ -46,7 +46,7 @@ func newSqliteCache(filename string) (*sqliteCache, error) {
return nil, err
}
return &sqliteCache{
- db: db,
+ db: db,
}, nil
}
@@ -122,6 +122,6 @@ func (s *sqliteCache) Topics() (map[string]*topic, error) {
}
func (c *sqliteCache) Prune(keep time.Duration) error {
- _, err := c.db.Exec(pruneMessagesQuery, time.Now().Add(-1 * keep).Unix())
+ _, err := c.db.Exec(pruneMessagesQuery, time.Now().Add(-1*keep).Unix())
return err
}
diff --git a/server/index.html b/server/index.html
index 94f65f17..45531dfb 100644
--- a/server/index.html
+++ b/server/index.html
@@ -33,7 +33,7 @@
ntfy.sh - simple HTTP-based pub-sub
ntfy (pronounce: notify) is a simple HTTP-based pub-sub notification service.
- It allows you to send desktop notifications via scripts from any computer, entirely without signup or cost.
+ It allows you to send notifications to your phone or desktop via scripts from any computer, entirely without signup or cost.
It's also open source if you want to run your own.
@@ -83,8 +83,8 @@
Subscribe via phone
- Once it's approved, you can use the Ntfy Android App to receive notifications directly on your phone. Just like
- the server, this app is also open source.
+ You can use the Ntfy Android App
+ to receive notifications directly on your phone. Just like the server, this app is also open source.
Subscribe via your app, or via the CLI
@@ -184,7 +184,7 @@
Privacy policy
Neither the server nor the app record any personal information, or share any of the messages and topics with
- any outside service. All data is exclusively used to make the service function properly. The notable exception
+ any outside service. All data is exclusively used to make the service function properly. The one exception
is the Firebase Cloud Messaging (FCM) service, which is required to provide instant Android notifications (see
FAQ for details).
diff --git a/server/server.go b/server/server.go
index 208cc454..c7e5afc0 100644
--- a/server/server.go
+++ b/server/server.go
@@ -204,6 +204,9 @@ func (s *Server) handlePublish(w http.ResponseWriter, r *http.Request, v *visito
return err
}
w.Header().Set("Access-Control-Allow-Origin", "*") // CORS, allow cross-origin requests
+ if err := json.NewEncoder(w).Encode(m); err != nil {
+ return err
+ }
s.mu.Lock()
s.messages++
s.mu.Unlock()
@@ -360,7 +363,7 @@ func (s *Server) updateStatsAndExpire() {
}
// Prune cache
- if err := s.cache.Prune(s.config.MessageBufferDuration); err != nil {
+ if err := s.cache.Prune(s.config.CacheDuration); err != nil {
log.Printf("error pruning cache: %s", err.Error())
}