-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nostr dm notifications #3051
Nostr dm notifications #3051
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this seems pretty dinished, despite being a draft.
Is this intentional?
I left some code style marks
@@ -0,0 +1,108 @@ | |||
const NotificationProvider = require("./notification-provider"); | |||
global.crypto = require("crypto"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line included?
global.crypto = require("crypto"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it, on Node 18 there is an error from the nostr-tools module that crypto is not defined. Node 19+ doesn't need it. There is a closed issue for nostr-tools about it: nbd-wtf/nostr-tools#192
I see they have a better method for Node 18 compatibility now, but I'm not sure how to implement it:
// node.js 18 and earlier requires globalThis.crypto polyfill.
import { webcrypto } from 'node:crypto';
// @ts-ignore
if (!globalThis.crypto) globalThis.crypto = webcrypto;
Here is the error with Node 18:
ReferenceError: crypto is not defined
at Object.encrypt (/home/ansible/uptime-kuma/node_modules/nostr-tools/lib/nostr.cjs.js:994:19)
at Nostr.send (/home/ansible/uptime-kuma/server/notification-providers/nostr.js:34:44)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Socket.<anonymous> (/home/ansible/uptime-kuma/server/server.js:1209:27)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include a comment that this is a polyfill for node <= 18
nip04, | ||
nip19 | ||
} = require("nostr-tools"); | ||
require("websocket-polyfill"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this included?
No other of the providers include this.
If you think this is needed, let's split this out of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it, on Node 18 there is an error from the nostr-tools module. Node 19+ doesn't need it.
TypeError: Cannot read properties of undefined (reading 'readyState')
at Object.close (/home/ansible/uptime-kuma/node_modules/nostr-tools/lib/nostr.cjs.js:566:14)
at Nostr.send (/home/ansible/uptime-kuma/server/notification-providers/nostr.js:66:23)
at async Socket.<anonymous> (/home/ansible/uptime-kuma/server/server.js:1209:27)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include a comment that this is a polyfill for node <= 18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this seems pretty dinished, despite being a draft.
Is this intentional?
I left some code style marks
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Thank you for the review and feedback. I'm new to open source contributions and JavaScript. I wanted to learn more about the Nostr protocol so I implemented this for my own use. The project contribution guidelines said to mark it as a draft. |
See https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma |
Co-authored-by: Frank Elsinga <frank@elsinga.de>
# Conflicts: # src/lang/en.json
I just realized that this pr is not working on arm v7, because there is no pre-built binary for the Feel free to continue this by opening a new pr if you have found a solution.
|
* Add nostr DM notification provider * require crypto for node 18 compatibility * remove whitespace * move closer to where it is used * simplify success or failure logic * don't clobber the non-alert msg * Update server/notification-providers/nostr.js * polyfills required for node <= 18 * resolve linter warnings * missing comma --------- Co-authored-by: Frank Elsinga <frank@elsinga.de> Co-authored-by: zappityzap <128872140+zappityzap@users.noreply.github.com>
This reverts commit b8bcb6f. Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
* Add nostr DM notification provider * require crypto for node 18 compatibility * remove whitespace * move closer to where it is used * simplify success or failure logic * don't clobber the non-alert msg * Update server/notification-providers/nostr.js * polyfills required for node <= 18 * resolve linter warnings * missing comma --------- Co-authored-by: Frank Elsinga <frank@elsinga.de> Co-authored-by: zappityzap <128872140+zappityzap@users.noreply.github.com>
This reverts commit b8bcb6f. Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
* Add nostr DM notification provider * require crypto for node 18 compatibility * remove whitespace * move closer to where it is used * simplify success or failure logic * don't clobber the non-alert msg * Update server/notification-providers/nostr.js * polyfills required for node <= 18 * resolve linter warnings * missing comma --------- Co-authored-by: Frank Elsinga <frank@elsinga.de> Co-authored-by: zappityzap <128872140+zappityzap@users.noreply.github.com>
This reverts commit b8bcb6f. Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
* ✨ feat: json-query monitor added Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: import warning error Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: br tag and remove comment Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: supporting compare string with other types Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: switch to a better lib for json query Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: better description on json query and using `v-html` in jsonQueryDescription element to fix `a` tags Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: result variable in error message Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: typos in json query description Co-authored-by: Frank Elsinga <frank@elsinga.de> * 📝 docs: `HTTP(s) Json Query` added to monitor list in `README.md` Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: needed white space in `README.md` Co-authored-by: Frank Elsinga <frank@elsinga.de> * Nostr dm notifications (#3051) * Add nostr DM notification provider * require crypto for node 18 compatibility * remove whitespace Co-authored-by: Frank Elsinga <frank@elsinga.de> * move closer to where it is used * simplify success or failure logic * don't clobber the non-alert msg * Update server/notification-providers/nostr.js Co-authored-by: Frank Elsinga <frank@elsinga.de> * polyfills required for node <= 18 * resolve linter warnings * missing comma --------- Co-authored-by: Frank Elsinga <frank@elsinga.de> * Drop nostr * Rebuild package-lock.json * Lint --------- Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> Co-authored-by: Frank Elsinga <frank@elsinga.de> Co-authored-by: zappityzap <128872140+zappityzap@users.noreply.github.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
* ✨ feat: added kafka producer Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: eslint warn Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: typings and auth problems Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: better variable name to trrack disconnection Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: grouping Kafka Producer special settings into one template Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * ✨ feat: add kafka producer translations into `en.json` Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: disable close-on-select on kafka broker picker Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * 🐛 fix: `en.json` invalid json (conflict resolve) Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> * Nostr dm notifications (#3051) * Add nostr DM notification provider * require crypto for node 18 compatibility * remove whitespace Co-authored-by: Frank Elsinga <frank@elsinga.de> * move closer to where it is used * simplify success or failure logic * don't clobber the non-alert msg * Update server/notification-providers/nostr.js Co-authored-by: Frank Elsinga <frank@elsinga.de> * polyfills required for node <= 18 * resolve linter warnings * missing comma --------- Co-authored-by: Frank Elsinga <frank@elsinga.de> * Drop nostr * Minor * Fix a bug of clone --------- Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev> Co-authored-by: Frank Elsinga <frank@elsinga.de> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This reverts commit b8bcb6f.
This reverts commit b8bcb6f.
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Adds notification provider for the nostr protocol: https://github.com/nostr-protocol/nostr
Notifications are sent as encrypted direct messages.
Type of change
Checklist
(including JSDoc for methods)
Screenshots (if any)