SatoshiPortal / cyphernode

Modular Bitcoin full-node microservices API server architecture and utilities toolkit to build scalable, secure and featureful apps and services without trusted third parties
MIT License
365 stars 69 forks source link

E-mail notifications on events #59

Open Kexkey opened 5 years ago

Kexkey commented 5 years ago

Have a way to send e-mails (to the admin) triggered on events.

For example:

This should be implemented inside its own container that all the other containers can use/call.

wiredcheetah commented 5 years ago

would running postfix in a docker work for this? need a different mailer?

darwin commented 5 years ago

I would suggest considering implementing generic notifications system which would log notifications locally into a file by default. I would bet some project like this already exists.

And then implementing e-mail as one of possible backends for delivering notifications. I personally would like to see keybase as another possible way how to consume notifications (a keybase bot posting into a group channel or sending messages directly into a 1-1 chat).

darwin commented 5 years ago

Just did a bit of googling and I think we need something like:

And use existing email plugin or write our own (e.g. I would do one for the keybase integration)

Both projects look quite heavy-weight and enterprise-y to me. Would be nice to have something lightweight, simple, docker-friendly and extensible with shell scripts (which means extensible by anything shell can call).

Kexkey commented 5 years ago

Hi darwin! Thanks for joining in! I like the approach of having something like a "Notification MQ" that can be picked up by whatever we plug-in (like an e-mailer, SMS sender, slack bot or whatever). It is a very nice idea and decoupled architecture.

Would you take that challenge? What part of it are you willing to take? The keybase integration? Let me think about how we would go about it and in the meantime let me know if you want to contribute.

darwin commented 5 years ago

Yes, I think this could be a good task for me to start contributing.

I can implement whole notification subsystem. And provide email and keybase as initial "output plugins".

You should maybe decide what existing technology to use (if any). Since you already have everything based on docker, maybe simple filtering of docker logs could be enough for our needs. And services would communicate events by printing to stdout. I would just implement a system of plugins which would implement triggers/actions. But as I said I don't want to be reinventing the wheel here, so I'm not afraid of using existing tools. Personally I'm leaning to use simple unix-y/shell tools when it makes sense.

Think about it with other project maintainers and give me some specs. No hurry.

Kexkey commented 5 years ago

Hi @darwin ! I added the broker and notifier components to Cyphernode as well as publishing/subscribing functionalities.

The broker is a lightweight pub/sub implementation called Eclipse Mosquitto (https://mosquitto.org/). Right now, the notifier is the only subscriber and it receives requests to call back URLs when something happens (for example, when a Bitcoin address receives a payment or when an OTS stamp is confirmed/upgraded). Current publisher for the callbacks is the proxy.

Anyway, I think the notifier should be the central piece that would take care of the notifications. Right now only the HTTP/S requests are supported, but we can easily add any other types of notifications.

The notifier is pretty straight forward. It can be rewritten in another language and made richer.

BTW the publish/subscribe mechanism may replace the http communication between cyphernode's components.

darwin commented 5 years ago

Thanks for the report. I'm going revisit Cyphernode in a week or two. Will look into this.