From d78f1a3ff935ea1d175f5fe00bfc33d97d6878eb Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 9 Dec 2022 20:28:12 +0000 Subject: [PATCH 1/8] Add uppercase letters to random topic name generation Signed-off-by: Yarden Shoham --- web/src/app/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/app/utils.js b/web/src/app/utils.js index 8b64b2c1..fa324ca1 100644 --- a/web/src/app/utils.js +++ b/web/src/app/utils.js @@ -242,7 +242,7 @@ export async function* fetchLinesIterator(fileURL, headers) { } export const randomAlphanumericString = (len) => { - const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; + const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; let id = ""; for (let i = 0; i < len; i++) { id += alphabet[(Math.random() * alphabet.length) | 0]; From 8d3f35f4f7ceedb005f540d8e822ed44c8867fd6 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sat, 10 Dec 2022 09:01:40 -0500 Subject: [PATCH 2/8] Thank you @p-samuel for your donation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c2926e3..25a05a75 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ appreciated. A big fat **Thank You** to the folks already sponsoring ntfy: + I'd also like to thank [DigitalOcean](https://www.digitalocean.com/) for supporting the project with $60/yr: From 265af01f9c21efb386e842fd82b11f76dd8714b5 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 10 Dec 2022 21:56:13 +0000 Subject: [PATCH 3/8] Add Gitpod configuration for quick setup of development environments With this change, any developer can simply open a development environment in Gitpod. The environment has docs, web, and binary being built on every code change. Also included the vscode extensions for Go and Docker. Signed-off-by: Yarden Shoham --- .gitpod.yml | 28 ++++++++++++++++++++++++++++ README.md | 8 ++++++++ docs/develop.md | 6 ++++++ 3 files changed, 42 insertions(+) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..6cccd8f2 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,28 @@ +tasks: + - name: docs + before: make docs-deps + command: mkdocs serve + - name: binary + before: | + npm install --global nodemon + make cli-deps-static-sites + command: | + nodemon --watch './**/*.go' --ext go --signal SIGTERM --exec "CGO_ENABLED=1 go run main.go serve --listen-http :2586 --debug --base-url $(gp url 2586)" + openMode: split-right + - name: web + before: make web-deps + command: cd web && npm start + openMode: split-right + +vscode: + extensions: + - golang.go + - ms-azuretools.vscode-docker + +ports: + - name: docs + port: 8000 + - name: binary + port: 2586 + - name: web + port: 3000 \ No newline at end of file diff --git a/README.md b/README.md index 25a05a75..c4885f59 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ [![Matrix space](https://img.shields.io/matrix/ntfy-space:matrix.org?label=Matrix+space)](https://matrix.to/#/#ntfy-space:matrix.org) [![Reddit](https://img.shields.io/reddit/subreddit-subscribers/ntfy?color=%23317f6f&label=-%20r%2Fntfy&style=social)](https://www.reddit.com/r/ntfy/) [![Healthcheck](https://healthchecks.io/badge/68b65976-b3b0-4102-aec9-980921/kcoEgrLY.svg)](https://ntfy.statuspage.io/) +[![Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/binwiederhier/ntfy) + **ntfy** (pronounce: *notify*) is a simple HTTP-based [pub-sub](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) notification service. It allows you to **send notifications to your phone or desktop via scripts** from any computer, entirely **without signup or cost**. @@ -59,6 +61,12 @@ Or, if you'd like to help translate πŸ‡©πŸ‡ͺ πŸ‡ΊπŸ‡Έ πŸ‡§πŸ‡¬, you can start im Translation status +### Quickly getting a development environment setup + +To get a quick working development environment you could use Gitpod. + +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/binwiederhier/ntfy) + ## Sponsors I have just very recently started accepting donations via [GitHub Sponsors](https://github.com/sponsors/binwiederhier). I would be humbled if you helped me carry the server and developer account costs. Even small donations are very much diff --git a/docs/develop.md b/docs/develop.md index f3da274a..fc65e4b2 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -22,6 +22,12 @@ server consists of three components: All of these components are built and then **baked into one binary**. +### Quickly getting a development environment setup + +To get a quick working development environment you could use Gitpod. + +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/binwiederhier/ntfy) + ### Navigating the code Code: From 321ed1266343fbe9e2ad634748d26cd9a90e428a Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sun, 11 Dec 2022 15:50:16 -0500 Subject: [PATCH 4/8] Changelog --- docs/releases.md | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/docs/releases.md b/docs/releases.md index cfb50825..b1de1509 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -12,28 +12,20 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release * Remove `--env-topic` option from `ntfy publish` as per [deprecation](deprecations.md) (no ticket) -## ntfy Android app v1.16.0 (UNRELEASED) +## ntfy Android app v1.16.0 +Released December 11, 2022 + +This is a feature and platform/dependency upgrade release. You can now have per-subscription notification settings +(including sounds, DND, etc.), and you can make notifications continue ringing until they are dismissed. There's also +support for thematic/adaptive launcher icon for Android 13. + +There are a few more Android 13 specific things, as well as many bug fixes: No more crashes from large images, no more +opening the wrong subscription, and we also fixed the icon color issue. **Features:** * Custom per-subscription notification settings incl. sounds, DND, etc. ([#6](https://github.com/binwiederhier/ntfy/issues/6), thanks to [@doits](https://github.com/doits)) * Insistent notifications that ring until dismissed ([#417](https://github.com/binwiederhier/ntfy/issues/417), thanks to [@danmed](https://github.com/danmed) for reporting) - -**Bug fixes:** - -* Android 5 (SDK 21): Fix crash on unsubscribing ([#528](https://github.com/binwiederhier/ntfy/issues/528), thanks to Roger M.) - -## ntfy Android app v1.15.2 (UNRELEASED) - -This release is mainly a platform and dependency upgrade release, sprinkled with lots and lots of bugfixes. This version -now targets SDK 33 (Android 13), and brings a few Android 13 specific improvements. Most prominently, ntfy now supports -thematic/adaptive launcher icons. - -Other than that, the app now doesn't crash anymore when you send large attachment images, and we fixed the notification -icon color. - -**Features:** - * Add thematic/adaptive launcher icon ([#513](https://github.com/binwiederhier/ntfy/issues/513), thanks to [@daedric7](https://github.com/daedric7) for reporting) **Bug fixes + maintenance:** @@ -42,6 +34,7 @@ icon color. * Simplify F-Droid build: Disable tasks for Google Services ([#516](https://github.com/binwiederhier/ntfy/issues/516), thanks to [@markosopcic](https://github.com/markosopcic)) * Android 13: Ask for permission to post notifications ([#508](https://github.com/binwiederhier/ntfy/issues/508)) * Android 13: Do not allow swiping away the foreground notification ([#521](https://github.com/binwiederhier/ntfy/issues/521), thanks to [@alexhorner](https://github.com/alexhorner) for reporting) +* Android 5 (SDK 21): Fix crash on unsubscribing ([#528](https://github.com/binwiederhier/ntfy/issues/528), thanks to Roger M.) * Remove timestamp when copying message text ([#471](https://github.com/binwiederhier/ntfy/issues/471), thanks to [@wunter8](https://github.com/wunter8)) * Fix auto-delete if some icons do not exist anymore ([#506](https://github.com/binwiederhier/ntfy/issues/506)) * Fix notification icon color ([#480](https://github.com/binwiederhier/ntfy/issues/480), thanks to [@s-h-a-r-d](https://github.com/s-h-a-r-d) for reporting) From 1235ea5bb546677d34cb86d96ae7da68d2097b8f Mon Sep 17 00:00:00 2001 From: Nick Farrell Date: Mon, 12 Dec 2022 13:39:02 +1100 Subject: [PATCH 5/8] Use prepared statement for bulk writes When executing the same statement multiple times, avoid the overhead of re-parsing the statement for each insert. --- server/message_cache.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/message_cache.go b/server/message_cache.go index 3972470b..95edd980 100644 --- a/server/message_cache.go +++ b/server/message_cache.go @@ -258,12 +258,23 @@ func (c *messageCache) addMessages(ms []*message) error { if c.nop { return nil } + if len(ms) == 0 { + return nil + } start := time.Now() tx, err := c.db.Begin() if err != nil { return err } defer tx.Rollback() + statement, err := tx.Prepare( + insertMessageQuery, + ) + if err != nil { + return err + } + defer statement.Close() + for _, m := range ms { if m.Event != messageEvent { return errUnexpectedMessageType @@ -291,8 +302,7 @@ func (c *messageCache) addMessages(ms []*message) error { if m.Sender.IsValid() { sender = m.Sender.String() } - _, err := tx.Exec( - insertMessageQuery, + _, err := statement.Exec( m.ID, m.Time, m.Topic, From 77ebf306a3237c05aa779854ed95bef7737cf45e Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Mon, 12 Dec 2022 09:41:23 -0500 Subject: [PATCH 6/8] Remove ad-type wording --- README.md | 9 ++------- docs/develop.md | 13 +++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c4885f59..2833ac9d 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,6 @@ Or, if you'd like to help translate πŸ‡©πŸ‡ͺ πŸ‡ΊπŸ‡Έ πŸ‡§πŸ‡¬, you can start im Translation status -### Quickly getting a development environment setup - -To get a quick working development environment you could use Gitpod. - -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/binwiederhier/ntfy) - ## Sponsors I have just very recently started accepting donations via [GitHub Sponsors](https://github.com/sponsors/binwiederhier). I would be humbled if you helped me carry the server and developer account costs. Even small donations are very much @@ -104,7 +98,8 @@ appreciated. A big fat **Thank You** to the folks already sponsoring ntfy: -I'd also like to thank [DigitalOcean](https://www.digitalocean.com/) for supporting the project with $60/yr: +I'd also like to thank [IntelliJ IDEA](https://www.jetbrains.com/idea/) for providing their awesome IDE to me for free, +and [DigitalOcean](https://www.digitalocean.com/) for supporting the project with $60/yr: diff --git a/docs/develop.md b/docs/develop.md index fc65e4b2..23a6c1bb 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -22,12 +22,6 @@ server consists of three components: All of these components are built and then **baked into one binary**. -### Quickly getting a development environment setup - -To get a quick working development environment you could use Gitpod. - -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/binwiederhier/ntfy) - ### Navigating the code Code: @@ -49,6 +43,13 @@ Build related: The `web/` and `docs/` folder are the sources for web app and documentation. During the build process, the generated output is copied to `server/site` (web app and landing page) and `server/docs` (documentation). +### Build/test on Gitpod +To get a quick working development environment you can use [Gitpod](https://gitpod.io), an in-browser IDE +that makes it easy to develop ntfy without having to set up a desktop IDE. For any real development, +I do suggest a proper IDE like [IntelliJ IDEA](https://www.jetbrains.com/idea/). + +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/binwiederhier/ntfy) + ### Build requirements * [Go](https://go.dev/) (required for main server) From 67221b015d9545a3129adf5eb27dde92c0185bca Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 12 Dec 2022 09:55:17 -0500 Subject: [PATCH 7/8] 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, From a50d65393efb839cce3dadd17a5782a98359334d Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 12 Dec 2022 10:54:53 -0500 Subject: [PATCH 8/8] Thank you @zugaldia and @NathanSweet for your donation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2833ac9d..de456be2 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,8 @@ appreciated. A big fat **Thank You** to the folks already sponsoring ntfy: + + I'd also like to thank [IntelliJ IDEA](https://www.jetbrains.com/idea/) for providing their awesome IDE to me for free, and [DigitalOcean](https://www.digitalocean.com/) for supporting the project with $60/yr: