From 67221b015d9545a3129adf5eb27dde92c0185bca Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 12 Dec 2022 09:55:17 -0500 Subject: [PATCH] Changelog --- docs/releases.md | 2 ++ server/message_cache.go | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/releases.md b/docs/releases.md index b1de1509..a2c69253 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -7,10 +7,12 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release **Features:** * Web: Generate random topic name button ([#453](https://github.com/binwiederhier/ntfy/issues/453), thanks to [@yardenshoham](https://github.com/yardenshoham)) +* Add [Gitpod config](https://github.com/binwiederhier/ntfy/blob/main/.gitpod.yml) ([#540](https://github.com/binwiederhier/ntfy/pull/540), thanks to [@yardenshoham](https://github.com/yardenshoham)) **Bug fixes + maintenance:** * Remove `--env-topic` option from `ntfy publish` as per [deprecation](deprecations.md) (no ticket) +* Prepared statements for message cache writes ([#542](https://github.com/binwiederhier/ntfy/pull/542), thanks to [@nicois](https://github.com/nicois)) ## ntfy Android app v1.16.0 Released December 11, 2022 diff --git a/server/message_cache.go b/server/message_cache.go index 95edd980..376c7611 100644 --- a/server/message_cache.go +++ b/server/message_cache.go @@ -267,14 +267,11 @@ func (c *messageCache) addMessages(ms []*message) error { return err } defer tx.Rollback() - statement, err := tx.Prepare( - insertMessageQuery, - ) + stmt, err := tx.Prepare(insertMessageQuery) if err != nil { return err } - defer statement.Close() - + defer stmt.Close() for _, m := range ms { if m.Event != messageEvent { return errUnexpectedMessageType @@ -302,7 +299,7 @@ func (c *messageCache) addMessages(ms []*message) error { if m.Sender.IsValid() { sender = m.Sender.String() } - _, err := statement.Exec( + _, err := stmt.Exec( m.ID, m.Time, m.Topic,