From 2696b65e7bbb7597aef03ed512a81479f4097ea1 Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Sun, 5 Jan 2025 17:55:20 +0000 Subject: [PATCH 01/15] FIX: Remove unnecessary dependency Curl is not an emacs package, this is removed. --- ntfy.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ntfy.el b/ntfy.el index ec36fc3..9006afa 100644 --- a/ntfy.el +++ b/ntfy.el @@ -7,21 +7,21 @@ ;; Modified: 2022-05-04 ;; Version: 0.1.2 ;; Keywords: ntfy notification push-notification pub-sub -;; Package-Requires: ((emacs "27.2") (curl)) +;; Package-Requires: ((emacs "27.2")) ;; SPDX-License-Identifier: MIT ;; This file is not part of GNU Emacs. ;;; Commentary: ;; Interface to use the https://ntfy.sh service (or self-hosted version) to send notification from Emacs. -;; +;; ;;; Code: (defcustom ntfy-server nil "Set server for ntfy service." :group 'ntfy :type 'string) - + (defcustom ntfy-topic nil "Set ntfy topic/channel." :group 'ntfy From 5e43c07cfa04605f33cfe7cf38ad546392553fb3 Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Sun, 5 Jan 2025 19:33:53 +0000 Subject: [PATCH 02/15] FIX: Added URL as dependency --- ntfy.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntfy.el b/ntfy.el index 9006afa..ad12cd8 100644 --- a/ntfy.el +++ b/ntfy.el @@ -7,7 +7,7 @@ ;; Modified: 2022-05-04 ;; Version: 0.1.2 ;; Keywords: ntfy notification push-notification pub-sub -;; Package-Requires: ((emacs "27.2")) +;; Package-Requires: ((emacs "27.2") (url "22.1")) ;; SPDX-License-Identifier: MIT ;; This file is not part of GNU Emacs. From 7f88bdd27f9d4010871c2418dec147933b30d9da Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Sun, 5 Jan 2025 19:36:46 +0000 Subject: [PATCH 03/15] FIX: need URL required --- ntfy.el | 1 + 1 file changed, 1 insertion(+) diff --git a/ntfy.el b/ntfy.el index ad12cd8..b519e4a 100644 --- a/ntfy.el +++ b/ntfy.el @@ -16,6 +16,7 @@ ;; Interface to use the https://ntfy.sh service (or self-hosted version) to send notification from Emacs. ;; ;;; Code: +(require 'url) (defcustom ntfy-server nil "Set server for ntfy service." From 0205d7dbd31e0295dea22bf85000a8fa1cf939aa Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Sun, 5 Jan 2025 19:38:55 +0000 Subject: [PATCH 04/15] FIX: moved from Curl process -> Emacs URL Lib --- ntfy.el | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ntfy.el b/ntfy.el index b519e4a..d6f4093 100644 --- a/ntfy.el +++ b/ntfy.el @@ -57,13 +57,13 @@ Custom HEADER and TAGS are set for the notification." (ntfy--publish-message message header tags)) (defun ntfy--publish-message (message &optional header tags) - "Publish message to server with curl with MESSAGE. + "Publish message to server with Emacs Lib URL with MESSAGE. Configured HEADER and TAGS are used unless specified." - (start-process "nfty.el" nil "curl" - "-H" (format "Title: %s" (or header ntfy-header)) - "-H" (format "Tags: %s" (or tags ntfy-tags)) - "-d" (format "%s" message) - (format "%s/%s" ntfy-server ntfy-topic))) + (let ((url-request-method "POST") + (url-request-data message) + (url-request-extra-headers `(("Title" . ,(or header ntfy-header)) + ("Tags" . ,(or tags ntfy-tags))))) + (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) (defun ntfy-send-url (url) "Send URL from mini-buffer." @@ -71,13 +71,13 @@ Configured HEADER and TAGS are used unless specified." (ntfy--publish-url url)) (defun ntfy--publish-url (url) -"Publish URL to server with curl." -(start-process "nfty.el" nil "curl" - "-H" (format "Title: %s" "Emacs shared a URL") - "-H" (format "Tags: %s" "link") - "-H" (format "Actions: view, %s, %s" url url) - "-d" (format "%s" url) - (format "%s/%s" ntfy-server ntfy-topic))) + "Publish URL to server with Emacs Lib URL." + (let ((url-request-method "POST") + (url-request-data (concat "Click to follow the shared URL;\n" url)) + (url-request-extra-headers `(("Title" . "Emacs shared a URL") + ("Tags" . "link") + ("Actions" . ,(format "view, View Link, %s" url url))))) + (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) (provide 'ntfy) ;;; ntfy.el ends here From 9abe595b725681b3ad2e72de018e22bc74b0775c Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Sun, 5 Jan 2025 19:40:17 +0000 Subject: [PATCH 05/15] VERSION BUMP --- ntfy.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ntfy.el b/ntfy.el index d6f4093..b0c7f9b 100644 --- a/ntfy.el +++ b/ntfy.el @@ -4,8 +4,8 @@ ;; Author: Shom Bandopadhaya ;; Created: 2022-04-30 -;; Modified: 2022-05-04 -;; Version: 0.1.2 +;; Modified: 2025-01-05 +;; Version: 0.2.0 ;; Keywords: ntfy notification push-notification pub-sub ;; Package-Requires: ((emacs "27.2") (url "22.1")) ;; SPDX-License-Identifier: MIT From 64a3a4f55c8627fd2a5071c60165ea992a782c77 Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Tue, 5 Aug 2025 13:14:32 +0100 Subject: [PATCH 06/15] Added Autoloads --- ntfy.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ntfy.el b/ntfy.el index b0c7f9b..b590193 100644 --- a/ntfy.el +++ b/ntfy.el @@ -39,17 +39,20 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de :group 'ntfy :type 'string) +;;;###autoload (defun ntfy-send-message (message) "Send ad-hoc MESSAGE from mini-buffer as notification." (interactive "sEnter message:") (ntfy--publish-message message)) +;;;###autoload (defun ntfy-send-message-with-header (header message) "Send ad-hoc MESSAGE from mini-buffer with custom HEADER as notification." (interactive "sEnter header: \nsEnter message: ") (setq ntfy-header header) (ntfy--publish-message message header)) +;;;###autoload (defun ntfy-send-message-with-header-and-tags (tags header message) "Send ad-hoc MESSAGE from mini-buffer. Custom HEADER and TAGS are set for the notification." @@ -65,6 +68,7 @@ Configured HEADER and TAGS are used unless specified." ("Tags" . ,(or tags ntfy-tags))))) (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) +;;;###autoload (defun ntfy-send-url (url) "Send URL from mini-buffer." (interactive "sEnter URL: \n") From 4d53b3c8a15d182768bcad2daa05f079ad05522e Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Tue, 5 Aug 2025 13:14:41 +0100 Subject: [PATCH 07/15] Removed package Requirement This upsets Elpaca as it trys to install url --- ntfy.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntfy.el b/ntfy.el index b590193..44d058a 100644 --- a/ntfy.el +++ b/ntfy.el @@ -7,7 +7,7 @@ ;; Modified: 2025-01-05 ;; Version: 0.2.0 ;; Keywords: ntfy notification push-notification pub-sub -;; Package-Requires: ((emacs "27.2") (url "22.1")) +;; Package-Requires: ((emacs "27.2")) ;; SPDX-License-Identifier: MIT ;; This file is not part of GNU Emacs. From 97db24dca074fbf600c62ca509e284dcb329e83d Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Fri, 15 Aug 2025 16:55:27 +0100 Subject: [PATCH 08/15] ntfy.el: Added main group --- ntfy.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ntfy.el b/ntfy.el index 44d058a..2f93d4c 100644 --- a/ntfy.el +++ b/ntfy.el @@ -18,6 +18,9 @@ ;;; Code: (require 'url) +(defgroup ntfy () + "Notification publishing in Emacs") + (defcustom ntfy-server nil "Set server for ntfy service." :group 'ntfy From ea4c4173f14de0294d9b33b3165cb3aac7f245a5 Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Fri, 15 Aug 2025 17:00:47 +0100 Subject: [PATCH 09/15] ntfy.el: added input checker --- ntfy.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ntfy.el b/ntfy.el index 2f93d4c..3677196 100644 --- a/ntfy.el +++ b/ntfy.el @@ -86,5 +86,24 @@ Configured HEADER and TAGS are used unless specified." ("Actions" . ,(format "view, View Link, %s" url url))))) (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) +(defun ntfy--check-inputs (message &optional header tags) + "Validates HEADER, MESSAGE, and TAGS for newlines before sending. + + HEADER, MESSAGE, and TAGS must be strings without newline characters. + If any argument contains a newline, signals a user-error." + ;; Check the 'message' string for a newline character + ;; TODO Message checks? + + (when (string-match-p "\n" header) + (user-error "Notification header cannot contain a newline")) + + ;; Regex will only match if every character is one of the following; + ;; - Any lowercase letter a-z OR + ;; - Any lowercase letter, a comma or underscore, followed by any lowercase letter + (unless (string-match-p "^\\([a-z]\\|[a-z][,_][a-z]\\)+$" tags) + (user-error "Notification Tags cannot contain anything other than the lower case +characters a-z, a comma, or an underscore"))) + + (provide 'ntfy) ;;; ntfy.el ends here From 8c87cf8a13f5ac1aedd933ac336f17cb68657172 Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Fri, 15 Aug 2025 17:01:45 +0100 Subject: [PATCH 10/15] ntfy.el: some text changes --- ntfy.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ntfy.el b/ntfy.el index 3677196..d1c654b 100644 --- a/ntfy.el +++ b/ntfy.el @@ -13,8 +13,9 @@ ;; This file is not part of GNU Emacs. ;;; Commentary: -;; Interface to use the https://ntfy.sh service (or self-hosted version) to send notification from Emacs. -;; +;; Interface to use the https://ntfy.sh service (or self-hosted version) to send +;; notification from Emacs. + ;;; Code: (require 'url) @@ -58,7 +59,7 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de ;;;###autoload (defun ntfy-send-message-with-header-and-tags (tags header message) "Send ad-hoc MESSAGE from mini-buffer. -Custom HEADER and TAGS are set for the notification." + Custom HEADER and TAGS are set for the notification." (interactive "sEnter tags (emoji codes, comma separated no spaces): \nsEnter header: \nsEnter message: ") (ntfy--publish-message message header tags)) From b0d48e4e8f8d1bba0d6181a474075f91d23b377d Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Fri, 15 Aug 2025 17:12:28 +0100 Subject: [PATCH 11/15] ntfy.el: add the ability to customise priority --- ntfy.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ntfy.el b/ntfy.el index d1c654b..a8f3c08 100644 --- a/ntfy.el +++ b/ntfy.el @@ -43,6 +43,16 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de :group 'ntfy :type 'string) +(defcustom ntfy-priority 3 + "Set the message priority for the notification." + :group 'ntfy + :type '(choice (const :tag "urgent/max" 5) + (const :tag "high" 4) + (const :tag "default" 3) + (const :tag "low" 2) + (const :tag "min" 1))) + + ;;;###autoload (defun ntfy-send-message (message) "Send ad-hoc MESSAGE from mini-buffer as notification." From 62a864cca893187839c70098336f6a9b92a0550e Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Fri, 15 Aug 2025 17:41:45 +0100 Subject: [PATCH 12/15] ntfy.el: ntfy--publish-message The function can now check inputs as well as change priority on the message. --- ntfy.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ntfy.el b/ntfy.el index a8f3c08..4be8f41 100644 --- a/ntfy.el +++ b/ntfy.el @@ -73,13 +73,20 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de (interactive "sEnter tags (emoji codes, comma separated no spaces): \nsEnter header: \nsEnter message: ") (ntfy--publish-message message header tags)) -(defun ntfy--publish-message (message &optional header tags) +(defun ntfy--publish-message (message &optional header tags priority) "Publish message to server with Emacs Lib URL with MESSAGE. -Configured HEADER and TAGS are used unless specified." + Configured HEADER and TAGS are used unless specified." + ;; Check the inputs. + (ntfy--check-inputs message + (if header header) + (if tags tags)) + + ;; If no error is thrown, send the message. (let ((url-request-method "POST") (url-request-data message) (url-request-extra-headers `(("Title" . ,(or header ntfy-header)) - ("Tags" . ,(or tags ntfy-tags))))) + ("Tags" . ,(or tags ntfy-tags)) + ("Priority" . ,(int-to-string (or priority ntfy-priority)))))) (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) ;;;###autoload From db7a17738b5ef3694d77e2390e0fb6ba0d13ed7a Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Fri, 15 Aug 2025 17:51:24 +0100 Subject: [PATCH 13/15] ntfy.el: bugfix priority The priority should be 1 to 5. and now the checks use a known good string or number --- ntfy.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ntfy.el b/ntfy.el index 4be8f41..0d2b6e5 100644 --- a/ntfy.el +++ b/ntfy.el @@ -78,8 +78,9 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de Configured HEADER and TAGS are used unless specified." ;; Check the inputs. (ntfy--check-inputs message - (if header header) - (if tags tags)) + (or header "valid") + (or tags "heart") + (or priority 1)) ;; If no error is thrown, send the message. (let ((url-request-method "POST") @@ -104,7 +105,7 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de ("Actions" . ,(format "view, View Link, %s" url url))))) (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) -(defun ntfy--check-inputs (message &optional header tags) +(defun ntfy--check-inputs (message &optional header tags priority) "Validates HEADER, MESSAGE, and TAGS for newlines before sending. HEADER, MESSAGE, and TAGS must be strings without newline characters. @@ -115,6 +116,11 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de (when (string-match-p "\n" header) (user-error "Notification header cannot contain a newline")) + ;; Check the priority + (if (or (> priority 5) + (< priority 1)) + (user-error "Notification priority cannot be greater than 5 or less than 1")) + ;; Regex will only match if every character is one of the following; ;; - Any lowercase letter a-z OR ;; - Any lowercase letter, a comma or underscore, followed by any lowercase letter From 9c3a02c842c19544e5eca7cee0cba7f776bff85b Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Mon, 29 Sep 2025 14:54:21 +0100 Subject: [PATCH 14/15] FIX: naming changes and more readme examples --- ntfy.el | 30 +++++++++++++++--------------- readme.org | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/ntfy.el b/ntfy.el index 0d2b6e5..fbee405 100644 --- a/ntfy.el +++ b/ntfy.el @@ -1,4 +1,4 @@ -;;; ntfy.el --- publish notification using ntfy.sh -*- lexical-binding: t; -*- +;;; ntfy.el --- publish notification using ntfy.sh -*- lexical-binding: t; -*- ;; Copyright (C) 2022 Shom @@ -17,7 +17,7 @@ ;; notification from Emacs. ;;; Code: -(require 'url) +(require 'url) ;; Built-in (defgroup ntfy () "Notification publishing in Emacs") @@ -52,7 +52,6 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de (const :tag "low" 2) (const :tag "min" 1))) - ;;;###autoload (defun ntfy-send-message (message) "Send ad-hoc MESSAGE from mini-buffer as notification." @@ -78,9 +77,9 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de Configured HEADER and TAGS are used unless specified." ;; Check the inputs. (ntfy--check-inputs message - (or header "valid") - (or tags "heart") - (or priority 1)) + (or header "header") + (or tags "tags") + (or priority 3)) ;; If no error is thrown, send the message. (let ((url-request-method "POST") @@ -97,30 +96,32 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de (ntfy--publish-url url)) (defun ntfy--publish-url (url) - "Publish URL to server with Emacs Lib URL." + "Publish URL to server with Emacs Lib URL. + +Ensure URL contains the correct scheme. e.g. HTTPS" (let ((url-request-method "POST") - (url-request-data (concat "Click to follow the shared URL;\n" url)) + (url-request-data "Click to follow the shared URL") (url-request-extra-headers `(("Title" . "Emacs shared a URL") ("Tags" . "link") + ("Priority" . "3") ("Actions" . ,(format "view, View Link, %s" url url))))) (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) -(defun ntfy--check-inputs (message &optional header tags priority) - "Validates HEADER, MESSAGE, and TAGS for newlines before sending. - HEADER, MESSAGE, and TAGS must be strings without newline characters. - If any argument contains a newline, signals a user-error." - ;; Check the 'message' string for a newline character +(defun ntfy--check-inputs (message &optional header tags priority) + "Validates HEADER, MESSAGE, TAGS and Priority before sending." ;; TODO Message checks? + ;; Header cannot have a new line in it. (when (string-match-p "\n" header) (user-error "Notification header cannot contain a newline")) - ;; Check the priority + ;; Check the priority, needs to be from 1 to 5 inclusive. (if (or (> priority 5) (< priority 1)) (user-error "Notification priority cannot be greater than 5 or less than 1")) + ;; Tags are particular, with what is allowed. ;; Regex will only match if every character is one of the following; ;; - Any lowercase letter a-z OR ;; - Any lowercase letter, a comma or underscore, followed by any lowercase letter @@ -128,6 +129,5 @@ Use comma separated string, see https://ntfy.sh/docs/publish/#tags-emojis for de (user-error "Notification Tags cannot contain anything other than the lower case characters a-z, a comma, or an underscore"))) - (provide 'ntfy) ;;; ntfy.el ends here diff --git a/readme.org b/readme.org index 7dd66c8..b89263d 100644 --- a/readme.org +++ b/readme.org @@ -9,12 +9,20 @@ The =ntfy.el= file can be downloaded and loaded via =load-file= and other instal Recommended: the package can be installed and configured using =straight.el= using: #+begin_src emacs-lisp -(use-package ntfy - :straight (ntfy :type git :host nil :repo "https://git.sr.ht/~shom/ntfy") - :config (setq ntfy-server "https://ntfy.sh" - ntfy-topic "mytopic" - ntfy-header "Notification from emacs" - ntfy-tags "purple_circle,loudspeaker")) + (use-package ntfy + ;; for straight + ;; :straight (ntfy :type git :host nil :repo "https://git.sr.ht/~shom/ntfy") + + ;; for elpaca + ;; :ensure ( :host :repo :files (:defaults "*.el")) + + ;; for the inbuilt package VC install, on emacs >= 30 + :vc (:url "https://git.sr.ht/~shom/ntfy" :rev :newest) + :config (setopt ntfy-server "https://ntfy.sh" + ntfy-topic "mytopic" + ntfy-header "Notification from emacs" + ntfy-tags "purple_circle,loudspeaker" + ntfy-priority 3)) #+end_src ** Configuration @@ -22,7 +30,8 @@ The following custom variables must be configured: - =nfty-server=: The URL of the server (including the =https://= part), ntfy.sh generously offers a free hosted version so it can be set to =https://ntfy.sh=, be please be mindful of how we use this free resource and review the [[https://ntfy.sh/docs/privacy/][privacy policy]] of the service. - =nfty-topic=: The topic or channel where the notification should be published. If using the public ntfy.sh service, ensure that is not an easily guessable topic. - =ntfy-header=: This is the title of the notification, the message is sent as the body of the notification. -- =ntfy-tags=: The emoji(s) that'll appear before the header message. Use comma separated (no spaces) string, see https://ntfy.sh/docs/publish/#tags-emojis for details. +- =ntfy-tags=: The emoji(s) that'll appear before the header message. Use comma separated (no spaces) string, see [[https://ntfy.sh/docs/publish/#tags-emojis]] for details. +- =ntfy-priority=: The priority of the message that is sent. This will change how the notification displayed and to what urgenc on other clients. See https://docs.ntfy.sh/publish/#message-priority for details * Usage Once the package is loaded and configured a notification can be sent by invoking the following commands interactively or programmatically: @@ -36,20 +45,27 @@ Once the package is loaded and configured a notification can be sent by invoking | =ntfy-send-url= | ~(ntfy-send-url URL)~ | |----------------------------------------+--------------------------------------------------------------| + +#+begin_src emacs-lisp + (let ((ntfy-header ))) +#+end_src + * Improvements This is the first Emacs package I've put together, contributions, suggestions for best practices, and constructive criticism is very much welcome and appreciated. Here are some of the potential improvements: - Improve documentation and testing. - [X] This has been tested on =Emacs 27.2= & =28.0.92= using =curl= on Pop!_OS (20.04 and 22.04) and Termux. - - [X] All functions are documented and there are no Flycheck errors or warnings. + - [X] All functions are documented and there are no Flycheck errors or warnings. - [ ] Test on other OSes. - Provide more functionality: - [X] Interactively and programmatically set the tag per message as an optional parameter. - - [X] Send URL as a clickable item from the Android notification shade. + - [ ] Send URL as a clickable item from the Android notification shade. - [ ] Special characters break this function. Might need to switch to JSON, can't url-encode curl header. - [ ] Send a file attachment. - [ ] Send Android intents. - - Stretch: - - [ ] Provide templates for Header and Tags as a pop-up selection list. - - [ ] Provide minor mode to capture all Emacs notifications and post them to pre-defined topics. +- Stretch: + - [ ] Provide templates for Header and Tags as a pop-up selection list. + - [ ] Tags completion? + - [ ] Header completion? + - [ ] Provide minor mode to capture all Emacs notifications and post them to pre-defined topics. From 54329db01fe2107aaa39c641baf7a63cf6653821 Mon Sep 17 00:00:00 2001 From: Ethan Moss Date: Mon, 29 Sep 2025 14:56:48 +0100 Subject: [PATCH 15/15] FEAT: Android intent and Scheduled delivery --- ntfy.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ntfy.el b/ntfy.el index fbee405..98d771b 100644 --- a/ntfy.el +++ b/ntfy.el @@ -107,6 +107,33 @@ Ensure URL contains the correct scheme. e.g. HTTPS" ("Actions" . ,(format "view, View Link, %s" url url))))) (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) +(defun ntfy--publish-android-intent (intent) + "Publish an android intent" + (let ((url-request-method "POST") + (url-request-data "Click") + (url-request-extra-headers `(("Title" . "Emacs shared a URL") + ("Tags" . "link") + ("Priority" . "3") + ("Actions" . ,(format "broadcast, Take picture, extras.cmd=pic, extras.camera=front"))))) + (url-retrieve-synchronously (format "%s/%s" ntfy-server ntfy-topic)))) + + +;; Scheduled Delivery +(defun ntfy--publish-message-plist (plist) + "Publish a message using a lisp PLIST + +The plist is converted to JSON and set to the NTFY server." + (let ((url-request-method "POST") + (url-request-data (json-encode `( :topic ,(or topic ntfy-topic) + :title ,(or header ntfy-header) + :tags ,(vconcat (or tags ntfy-tags)) + :priority ,(or priority ntfy-priority) + :message "This is a test message" + :delay nil + :actions nil + :click nil)))) + (url-retrieve-synchronously ntfy-server))) + (defun ntfy--check-inputs (message &optional header tags priority) "Validates HEADER, MESSAGE, TAGS and Priority before sending."